Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 simple query

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2002-11-04 : 19:21:36
I have two tables with identicle structures. I want to be able to run a query that returns the records from both tables that don't have a corresponding match in the other table on field1. How can I do this?

Thanks,
Lane

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-11-04 : 19:33:25
How about


SELECT * FROM TABLE1 WHERE TABLE1.FIELD1
NOT IN (SELECT FIELD1 FROM TABLE2)

UNION

SELECT * FROM TABLE2 WHERE TABLE2.FIELD1
NOT IN (SELECT FIELD1 FROM TABLE1)




Go to Top of Page
   

- Advertisement -