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
 SQL: not in; via joins

Author  Topic 

dendeze
Starting Member

2 Posts

Posted - 2010-07-08 : 07:56:24
Hey,
I have two tables

table1 with fields :veld1
table2 with fields: veld1

values in table1: A, B, C
values in table2: B,C,D

through next sql

select * from table1 where veld1 not in (select * from table2)

i get : A

Now i would like to do the same but via join commands

Is this possible?

thx in advance

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-07-08 : 07:59:16
SELECT <fieldList>
FROM Table1 T1
LEFT JOIN Table2 T2
ON T2.veld1 = T1.veld1
WHERE T2.veld1 IS NULL
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-08 : 08:01:48
select t1.* from table1 as t1 left join table2 as t2 on t1.veld1=t2.veld1
where t2.veld1 is null

Madhivanan

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-08 : 08:02:31


Madhivanan

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

Sachin.Nand

2937 Posts

Posted - 2010-07-08 : 08:02:43
select * from table1 t1 left join table2 t2 on t1.veld1=t2.veld2
where t2.veld1 is null


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-07-08 : 08:03:15



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

dendeze
Starting Member

2 Posts

Posted - 2010-07-08 : 08:17:09
thx for the replies, they are all correct.

and so quick
me like this forum :D
Go to Top of Page
   

- Advertisement -