Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Select data with multiple NOT IN where class

$
0
0
Hi, Please can anyone help me with below sql query. I need to select data from a table based on multiple NOT IN where conditions
For exmaple- From below table select Emp Id where Dept not in (D1,D2) and Role not in (R1, R2). There is an AND relation between these two condition i.e the condition should be applied only when both the conditions (Dept+Role) are satisfied. For example the query should select Emp id=1 as only Dept = D1 but Role is not R1 or R2. Similarly Emp id= 2 should not be displayed as both the conditions are satisfied.

Emp id Dept Role
1 D1 R3
2 D2 R2
3 D3 R3
4 D1 R3
5 D1 R2
6 D3 R2

Many thanks for your help in advance.

Viewing all articles
Browse latest Browse all 13329

Trending Articles