Excluding records in a query

V

Valentine

Select tableA.Field1, tableA.attribute
from tableA join TableB on tableA.Field1 <> tableB.Field1

--OR--

SELECT Table1.Field1, Table1.attribute
FROM Table1 where field1 not in (select field1 from
table2);

Both will work. I believe first one is higher performing
 
J

John Vinson

Select tableA.Field1, tableA.attribute
from tableA join TableB on tableA.Field1 <> tableB.Field1

--OR--

SELECT Table1.Field1, Table1.attribute
FROM Table1 where field1 not in (select field1 from
table2);

Both will work. I believe first one is higher performing

I'm not sure about performance, but it will certainly not return the
desired results! It will give a Cartesian join matching every record
in TableA with every record in TableB *except* the one record which
matches on Field1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top