SQLTeam.com | Weblogs | Forums

Select from 1 table based on another table

Hi There,
Can you help please.
I need to be able to select data from a table based on the information in another table.
So something like:
SELECT * from Table1 where Table2.quoted = Table1.Quoted

Thanks for your help.

Best Regards,

Steve.

hope this helps :slight_smile:
table1.quoted and table2.quoted have to be the same data types

select * from table1
where table1.quoted in ( select table2.quoted from table2 )

For best efficiency, use an EXISTS check:

SELECT * FROM Table1 WHERE EXISTS(SELECT 1 FROM Table2 WHERE Table2.quoted = Table1.Quoted)

Thanks for your help, I really appreciate it.

Best Regards,

Steve.