我有两张桌子
人们
name id
man1 456
man2 123
man3 789
笔记
content id
testing 123
hello 456
SELECT DISTINCT id FROM people是 的超集SELECT DISTINCT id FROM notes。
我想写两个查询。一种从表中选择所有记录people,其中存在记录,notes其中 id 列中的notes值等于people.id。
name id
man1 456
man2 123
另一个从表中选择不存在people记录的所有记录,其中 id 列中的值等于notesnotespeople.id
content id
man3 789