Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL help

Status
Not open for further replies.

WP

Programmer
Nov 30, 1999
463
CH
I have two tables that share the same key field (ID).&nbsp;&nbsp;I need to select all records in the first table (Table1) where there is no match in the second table.<br><br>Can anyone help with the SQL for this. <p>Bill Paton<br><a href=mailto:william.paton@ubsw.com>william.paton@ubsw.com</a><br><a href=
 
Simple answer is....<br><br><FONT FACE=monospace>select * from table1 <br>&nbsp;&nbsp;&nbsp;&nbsp;where ID not in (select ID from table2)</font><br><br>If you had thousands of rows in your tables it would probably be better to avoid sub-selects and to do it in two passes using a temp table. <p> <br><a href=mailto: > </a><br><a href= home</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top