Reputation: 35
I am new to database programming.
I have a database structure here.
http://www.sqlfiddle.com/#!4/b1174
I want to Fetch all the employee having no address.
It should fetch employee with id as 3.
How i can do this?
Upvotes: 0
Views: 317
Reputation: 3807
select * from emp as e
left join address as a on e.id=a.id
where a.id is null
Upvotes: 1
Reputation: 635
This query should do
select * from emp where id not in(select distinct(id) from address);
Upvotes: 0