MySQL - EXISTS 和 NOT EXISTS

语法规则:
 
SELECT * FROM tableName t WHERE 1 = 1 AND 2 = 2 AND EXISTS (SELECT * FROM tableName t2 WHERE t.id = t2.proj_id)
 

SELECT * FROM tableName t WHERE 1 = 1 AND 2 = 2 AND NOT EXISTS (SELECT * FROM tableName t2 WHERE t.id = t2.proj_id)

 

posted @ 2017-11-19 17:18  AndreMao  阅读(193)  评论(0编辑  收藏  举报