Only include rows where the joined fields from both tables are equal

  • Thread starter newkid via AccessMonster.com
  • Start date
N

newkid via AccessMonster.com

Is it possible to make a join on a query, and not include the rows where the
joined feilds are equal?
 
D

Douglas J. Steele

You can go into the SQL statement and change

ON Table1.Field1 = Table2.Field1

to

ON Table1.Field1 <> Table2.Field1

However, are you sure you want that? It has the potential of giving you
thousands of rows...
 
K

Krzysztof Naworyta

newkid via AccessMonster.com <u51019@uwe>

| Is it possible to make a join on a query, and not include the rows
| where the joined feilds are equal?

select t1.*, t2.*
from
table1 t1
left join
table2 t2
on
t1.fieldA = t2.fieldA
where
t2.fieldA is Null

UNION ALL

select t1.*, t2.*
from
table1 t1
right join
table2 t2
on
t1.fieldA = t2.fieldA
where
t1.fieldA is Null
 

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