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\$
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.