select query

G

G venkatesh

Hi All,

I have following 2 tables

1. Employee table with Emp_ID and Emp_Name
2. Vehicle table with Veh_ID, Emp_ID, Vehicle
And both are related with one to many relationship.

In these case, Can can I know the list of employees having Car and Bike. The
list should not include if employee is having only Car or only Bike or (Car
and Van) Or (Bike and Van)

Regards
Venkatesh
 
J

John Spencer

Simplest method is probably to use two sub-queries in the WHERE clause.

SELECT E.Emp_ID, E.Emp_Name
FROM Employee as E
WHERE E.Emp_ID IN
(SELECT V.Emp_ID
FROM Vehicle as V
WHERE V.Vehicle= 'Car')
AND
E.Emp_ID IN
(SELECT V2.Emp_ID
FROM Vehicle as V2
WHERE V2.Vehicle= 'Bike')

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top