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
 Transact-SQL (2000)
 Select non matches

Author  Topic 

Rliss
Starting Member

31 Posts

Posted - 2006-10-19 : 12:32:44
Let's say that I have to tables that have the same layout.

Tab1
linkset_name
------------
LS1
LS2
LS3

and

Tab2
linkset_name
------------
LS5
LS4
LS1

What I need to do is select all the linkset_name from Tab2 that do NOT exist in Tab1. In this example the results that I am looking for:

linkset_name
------------
LS5
LS4

Thanks in advance...

RLiss

nr
SQLTeam MVY

12543 Posts

Posted - 2006-10-19 : 12:43:35
select *
from Tab2 where linkset_name not in (select linkset_name from Tab1)

select t2.*
from Tab2 t2
left join Tab1 t1
on t1.linkset_name = t2.linkset_name
where t1.linkset_name is null

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-21 : 07:33:42
Rliss, Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2006-10-23 : 09:44:29
Beware NULL ...

Jay White
Go to Top of Page
   

- Advertisement -