Comparing field data in two tables

Hi guys

I have two sql server tables called “table1” & “table2”.

“table1” has the following fields:

“make”, “model” & “dealername”

“table2” has the following fields:

“make”, “model” & “approveddealername”

What I need to to is compare the data in the “dealername” field in “table1” with the data in the “approveddealername” field in “table2”.

So, let’s say the following records/data is in the “dealername” field in “table1”:

stevescars
rodcars
mikescars
larryscars
davescars

and the following is in the “approveddealername” field in “table2”

stevescars
rodcars
larryscars
davescars

I basically need to show:

mikescars

on my asp page. What statement do I need to use for this? Any help would be fully appreciated.

Best regards

Rod from the UK

So you want al dealer names from table1 that are NOT present in table 2.
What you need is a LEFT JOIN :


SELECT
   table1.dealername
FROM table1
LEFT JOIN table2
ON table1.dealername = table2.approveddealername
WHERE table2.approveddealername IS NULL

Excellent - Thanks Guido!

Best regards

Rod from the UK