下表中有两个字段,即a和b,如下所示:
create table employe
(
empID varchar(10),
department varchar(10)
);
插入一些记录:
insert into employe values('A101','Z'),('A101','X'),('A101','Y'),('A102','Z'),('A102','X'),
('A103','Z'),('A103','Y'),('A104','X'),('A104','Y'),('A105','Z'),('A106','X');
select * from employe;
empID department
------------------
A101 Z
A101 X
A101 Y
A102 Z
A102 X
A103 Z
A103 Y
A104 X
A104 Y
A105 Z
A106 X
Note:现在我想展示一位员工,他只属于Z
和Y
部门.
Expected Result:
如果条件为:Z
和Y
,则结果应为:
empID
------
A103
如果条件为:Z
和X
,则结果应为:
empID
------
A102
如果条件为:Z
X
和Y
,则结果应为:
empID
------
A101
104: I want to do it in the 100 clause only (don't want to use the 101 and 102 clauses), because I'm going to include this one in the other 100 also.