Click to See Complete Forum and Search --> : Select * from Table where record doesn't exist in other table


mparker1113
01-21-2007, 11:28 PM
Hi,

I have two tables, each with a similar field.

The first table has priority, so I take all the values from there and put them into a temp table. (select * from table1 where criteria).

Then, I want to get the critera for table2, but not where the samefield value is already in my temptable (select * from table2 if sameField is not in tempTable)

I have tried many solutions, but this is eluding me.

Is this possible to do?

russell
01-22-2007, 12:49 AM
SELECT fieldList
FROM TableA a
LEFT JOIN
TableB b
On a.keyField = b.keyField
WHERE b.keyField is NULL

mparker1113
01-22-2007, 01:21 AM
Thank you, that was it exact. LEFT JOIN

russell
01-22-2007, 01:28 AM
very welcome. happy to help :)