Excluding records in a query

  • Thread starter Thread starter Valentine
  • Start date Start date
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
 
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.
 
Back
Top