select NAME from WTUSER2 where NAME not in(select EN_NAME from WORKITEM_CREATOR) and NAME not in(select EN_NAME from NOT_LOGIN_USER)
------解决方案-------------------- 对,象这样的sql,还有种 exists 和not exists 的写法 SELECT NAME FROM wtuser2 a WHERE NOT EXISTS (SELECT en_name FROM workitem_creator b WHERE a.NAME = b.en_name) AND NOT EXISTS (SELECT en_name FROM not_login_user c WHERE a.NAME = c.en_name)
------解决方案-------------------- 可以可以可以
------解决方案-------------------- 对,但是not in 效率普通很慢,建议使用 not exists 替换,较高效率的写法如下:
SELECT NAME FROM wtuser2 a WHERE NOT EXISTS ((SELECT en_name FROM workitem_creator union all SELECT en_name FROM not_login_user ) c WHERE a.NAME = c.en_name)
------解决方案-------------------- 如果只是单纯的谈这个SQL那么你正确了。
------解决方案-------------------- 语法没问题,如果条件有null时会影响结果集,建议用exists/not exists判断真假的方法
------解决方案--------------------