sql 语句比较
两个很基础的SQL 可是我一不小心就写错了。特此记录。
SELECT * FROM `jk_usertags` ut WHERE ut.`id` NOT IN (SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid)
SELECT * FROM `jk_usertags` ut ,(SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid) test WHERE ut.`id` NOT IN (test.tagid)
SELECT * FROM `jk_usertags` ut ,(SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid) test WHERE ut.`id` NOT IN (test.tagid)
第一个sql 先查询(SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid)
再SELECT * FROM `jk_usertags` ut WHERE ut.`id` NOT IN (SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid)
第二个sql (SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid) 先查出这个,然后把这个当成一个表
再SELECT * FROM `jk_usertags` ut ,(SELECT tagid FROM `jk_tagvsuser` GROUP BY tagid) test WHERE ut.`id` NOT IN (test.tagid)