(例如,通过比较两个表
简化的情况表:
select count(1) from table_a; --> returns 5 results
select count(1) from table_b; --> returns 4 results
select count(1) from table_a, table_b2 b
where b.id_ab like a.id_ab; --> returns 4 results
select count(1) from table_a, table_b2 b
where b.id_ab not like a.id_ab; --> returns unexpected result
SQL:
尝试这样做(除了),但遇到错误。
select a.id_ab from table_a a, table_b b except select a.id_ab from table_a, table_b2 b
where b.id_ab not like a.id_ab;
或如何使用union来做到这一点?例如
(Select * from table_a except select * from table_b) Union All (Select * from table_b except select record_id from table_a);
预期结果:
谢谢。
感谢legendofawesomeness。完美的作品。 – user1872384