1
\$\begingroup\$

I'd like to Select columns from Table 1 with a Row Filter, Select columns from Table 2 and join.

This works but it's a bit verbose. I was wondering if there is a cleaner way to write this.

SELECT * FROM 
  ((SELECT JOB_NUM, ITEM_NUMBER, DATE_COMPLETED, QTY_COMPLETED, STD_USAGE, ACTUAL_USAGE FROM JOB_ROUTERS WHERE RESOURCE_CODE == "TDWELD") AS JOBS
 LEFT JOIN
(SELECT ITEM, DESCRIPTION FROM ITEM_ATTRIBUTE) as item
  ON JOBS.ITEM_NUMBER == ITEM.ITEM)
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

There is no need to do the deep abstraction for the Select *. You can simply reference the columns you want and include them in the result...

SELECT JOB_NUM,
       ITEM_NUMBER,
       DATE_COMPLETED,
       QTY_COMPLETED,
       STD_USAGE,
       ACTUAL_USAGE,
       ITEM,
       DESCRIPTION
FROM JOB_ROUTERS
LEFT JOIN ITEM_ATTRIBUTE
       ON JOBS.ITEM_NUMBER == ITEM_ATTRIBUTE.ITEM
WHERE RESOURCE_CODE == "TDWELD"
\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.