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
 General SQL Server Forums
 New to SQL Server Programming
 Getting results from table1 that are not in table2

Author  Topic 

reado
Starting Member

2 Posts

Posted - 2005-09-23 : 04:18:52
Hi,
I have a problem I have two tables, table1 my main table and table2 my secondary table.
Table1 has lots of records with a field for a unique transaction number, table2 also has a field for a transaction number.
Table 2 only has a 10 entries in with the same transaction number of
10 of the entries in table1.
My question is how do I get all the records from table1 that DONT have a corrisponding transaction number in table2.

Thanks
Paul

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-09-23 : 04:22:28
select a.*
from table1 a
where not exists(select b.* from table2 b where a.id = b.id)

something along those lines


Duane.
Go to Top of Page

reado
Starting Member

2 Posts

Posted - 2005-09-23 : 04:27:01
thank you thank you thank you thank you thank you thank you
You dont how long I have tried to get this working and you did it in one easy step.

YOU ARE THE BEST!!!!!!!
Go to Top of Page
   

- Advertisement -