Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
pasumpon
Starting Member
1 Post |
Posted - 2012-11-28 : 08:58:39
|
table name : employeeit contain field name : emp_id emp_id values 1,3,5,7,9,10MY question is if put condition in where statement like " where emp_id in ('1','2','3','4')" ( these values are i m inputing into the query)my output should be emp_id 2,4 what query condition i need to put . plz help me |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-28 : 09:12:03
|
Reverse the logic, for example: SELECT * FROM ( VALUES (1),(2),(3),(4)) t(emp_id)WHERE NOT EXISTS(SELECT * FROM Employee e WHERE e.emp_id = t.emp_id) |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-11-28 : 10:38:32
|
[code]Select E.Id from Employee EWhere emp_id in (1,2,3,4)and NOT Exists(Select * from Employee Where emp_id = E.emp_id)[/code] |
|
|
|
|
|
|
|