union和distinct 的使用

来源:互联网 发布:avision扫描仪软件 编辑:程序博客网 时间:2024/06/05 10:23
insert into use_message(itemid,Category,staff_no,message,isSend) select '4875','Lib', c.staff_no ,'','1'from (select distinct  b.staff_no from (select  staff_no from employee where department in (select Department from (SELECT Department FROM xhs_Department WHERE Department in ('170','171','N1','E1','W1','S1','M1','H1')  union SELECT Department FROM xhs_Department WHERE PDepartment_no IN (SELECT Department FROM xhs_Department WHERE Department in ('170','171','N1','E1','W1','S1','M1','H1') ) union SELECT Department FROM xhs_Department WHERE PDepartment_no IN (SELECT Department FROM xhs_Department WHERE PDepartment_no IN (SELECT Department FROM xhs_Department WHERE Department in ('170','171','N1','E1','W1','S1','M1','H1') ))) a)unionselect  staff_no from employee where department in (select Department from (select Department from xhs_Department where Country in ('')) a)unionselect  staff_no from employee where department in (select Department from (select Department from xhs_Department where Brand in ('')) a)) b) c

0 0
原创粉丝点击