How to select data from two table with out using "NOT IN" in sql server? -


i have 2 tables

emp1 id | name 1  | x 2  | y 3  | z  emp2 id | salary 1  | 10 2  | 20 

i want show ids emp1 not present in emp2 out using not in

so result should this

id 3 

now have done :

select  e1.id emp1 e1 left join  emp2 e2 on e1.id <> e2.id  

but getting :

id 1 2 3 3 

so should ?? out using not in

try left join is null condition below

select e1.id  emp1 e1 left join emp2 e2 on e2.id = e1.id e2.id null 

or not exists condition below

select e1.id  emp1 e1 not exists (   select 1   emp2 e2   e2.id = e1.id ) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -