Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a table,

Employee_Name Employee_ID Employee_NO
BEN 1235 1
PHILLIP 1234 1
DAVID 1245 2
ALEX 1248 2
ALICIA 1247 3

I would like to get this output as

Employee_Name Employee_ID Employee_NO
BEN 1235 1
PHILLIP 1234 1
DAVID 1245 2
ALEX 1248 2

Please LET ME KNOW THE QUERY

What I have tried:

i have tried

Select * from Employee where Employee_NO = 1 and Employee_NO = 2, but not getting the output.
Posted
Updated 16-Oct-18 10:01am

1 solution

Employee_NO = 1 and Employee_NO = 2
This would require each row to match both (Employee_NO = 1) AND (Employee_NO = 2) simultaneously.

You have a few options:
SQL
-- the simple version, number must be 1 or 2
WHERE (Employee_NO = 1)
OR    (Employee_NO = 2)

-- This returns a range of results. Good if IDs are contiguous
WHERE Employee_NO BETWEEN 1 AND 2

-- This returns multiple results based on ID, can be populated with a sub-query as well
WHERE Employee_NO IN (1, 2)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900