Reputation: 3978
I have a query which looks like
SELECT * FROM mytable mt
WHERE 1=1
AND mt.column_1 IN (SELECT id FROM employee WHERE salary >10000)
OR mt.column_2 IN (SELECT id FROM employee WHERE salary >10000)
I know the above query is not looking good even though it is getting my job done. I did google but could not find help. The reason I ask is the actual scenario the 'employee' table is temp table which is filled with data at the upper levels of the strored_procedure and this particular is my final select statement for the procedure.
Upvotes: 0
Views: 67
Reputation: 81940
I think a simple JOIN
would do the trick
SELECT mt.*
FROM mytable mt
JOIN (SELECT id FROM employee WHERE salary >10000) B
on mt.column_1=B.ID or mt.column_2=B.ID
Upvotes: 2