select id from table
= 260 595 记录
select id from table
left join table2 on table2.id = table.parent
= 260 595 记录
select id from table
inner join table2 on table2.id = table.parent
= 260 192 记录
找出table
中哪些记录有错误(不存在)的最简单方法是什么,以便我可以纠正它们?
感谢。
答案 0 :(得分:2)
使用它(它会在表格中给出你在table2中没有相应记录的id):
select id
from table left join table2
on table2.id = table.parent
where table.parent is null
答案 1 :(得分:2)
select id from table left join table2 on table2.id = table.parent
EXCEPT
select id from table inner join table2 on table2.id = table.parent
答案 2 :(得分:0)
select id from table inner join table2 on table2.id <> table.parent