user3408958
user3408958

Reputation: 35

Fetch the employee having no address?

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

Answers (2)

AK47
AK47

Reputation: 3807

    select * from emp as e
left join address as a on e.id=a.id
where a.id is null

Upvotes: 1

Sree
Sree

Reputation: 635

This query should do

select * from emp where id not in(select distinct(id) from address);

Upvotes: 0

Related Questions