Watch out though, NULL values can bite you in the butt with queries like this. We just had a situation where we had a table of 84 records in table A and many more in table B
SELECT claim_id from A where claim_id in (select claim_id from table B) -- This returns 75 rows SELECT claim_id from A where claim_id not in (select claim_id from table B) -- This returns 0 rows. It had to do with NULL values in the claim_id field in table B Therefore, I like to use join syntax more. SELECT claim_id from A LEFT JOIN B on a.claim_id = b.claim_id where b.claim_id is null On 8/19/05, G <[EMAIL PROTECTED]> wrote: > It's not particularly efficient, if the tables get large, but: > > SELECT Table2.id > FROM Table2 > WHERE Table2.id NOT IN (SELECT Table1.id FROM Table1) > > >I can do this with two queries, but I seem to remember there's a way > > to do it with just one. > > > > I have two tables, Table1 and Table2. > > > > I want a recordset containing all the Table2 IDs that are NOT in the > > Table1 table. > > I know there's an SQL statement, a join, to do that..but I just can't > > remember it! > > 0_0 > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Flash for programmers - Flash MX Pro http://www.houseoffusion.com/banners/view.cfm?bannerid=56 Message: http://www.houseoffusion.com/lists.cfm/link=i:5:170371 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
