Select users belonging only to particular departments

后端 未结 12 2249
挽巷
挽巷 2021-02-18 12:49

I have the following table with two fields namely a and b as shown below:

create table employe
(
    empID varchar(10),
    department varchar(10)
);
         


        
12条回答
  •  终归单人心
    2021-02-18 13:44

    for If condition is : Z and Y

       SELECT EMPID FROM EMPLOYE WHERE DEPARTMENT='Z'  AND 
       EMPID IN (SELECT EMPID FROM EMPLOYE WHERE DEPARTMENT ='Y')AND
       EMPID NOT IN(SELECT EMPID FROM EMPLOYE WHERE DEPARTMENT NOT IN ('Z','Y'))
    

提交回复
热议问题