# Miscellaneous > Structured Query Language (SQL) >  SQL Query Help

## Mauve

Hello Guys,
This might be a very simple problem but i can't seem to write the query for it.

I have a table with two columns
Employee Code  -  Dept Code
A - 1
B - 1

A - 2
C - 2

B - 3
D - 3

A - 4
B - 4
D - 4

A - 5
D - 5

A - 6
B - 6
D - 6
.....

now for a list(entered by a user) of Employee Ids say (A,B,D) I need a query (not a stored procedure) to get all the dept codes which have all the three employee ids.
So above it should return 4 and 6.

----------


## skhanal

How about using INTERSECT statement

SELECT Deptcode 
FROM table
where employeeid='A'
INTERSECT
SELECT Deptcode 
FROM table
where employeeid='B'
INTERSECT
SELECT Deptcode 
FROM table
where employeeid='D'

----------

