我有这张桌子...

id          name          location          date_created
--          ----          --------          ------------

15641       Maybel        New York          2015-09-15
84194       Joseph        Arkansas          2015-02-03
36479       Frank         Illinois          2015-10-28
19804       Samantha      San Francisco     2015-11-05
67811       Charles       Texas             2015-11-05


...和这张桌子...

id          name          location          created_at
--          ----          --------          ----------
15641       Maybel        New York          2015-09-15
84194       Joseph        Arkansas          2015-02-03
36479       Frank         Illinois          2015-10-28
78916       Logan         Philadelphia      2015-12-01
26799       George        Mississippi       2015-12-10


我需要的是...

id          name          location          created_at
--          ----          --------          ----------
19804       Samantha      San Francisco     2015-11-05
67811       Charles       Texas             2015-11-05


因此,基本上我需要一个查询来仅显示表1中未在表2中找到的记录。谢谢!

最佳答案

你可以用这个

SELECT *
FROM table1
WHERE id NOT IN (SELECT id FROM table2)

关于mysql - 提取在另一个表上找不到的记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36709956/

10-11 06:09
查看更多