Need a query with nonintersection results

marko

Registered User.
Local time
Today, 15:06
Joined
Dec 20, 2002
Messages
24
Hello!

How can I make a query which will, as results, return all the rows which are not identical in joined fields? Example:

Tables in the query:

Table1:
John
Luke
Matthew
Mark

Table2:
John
Luke

Results:

I get:
query1:
John
Luke

I would like to get:
query2:
Matthew
Mark

Thank you!

Marko
 
The basic query is:
Select T1.NAME
From Table1 as T1
Left Join Table2 as T2 on T2.Name = T1.Name
Where T2.Name is null
OR
Select T1.Name
From Table1 as T1
Where T1.Name not in
(Select Distinct T2.Name from Table2 as T2)

If you want name not appearing in both, you have to reverse it with a UNION between the two queries
 
Thank you FoFa, works great!

Marko
 

Users who are viewing this thread

Back
Top Bottom