-- A和B兩個表 數據是否一致
select 自定義
from A left join B on A.id = B.id
where B.id is null
註釋:這樣查詢的結果是A表中有而B表中沒有的數據sql
select 自定義
from B left join A on A.id = B.id
where A.id is null
註釋:這樣查詢的結果是B表中有而A表中沒有的數據 io
可使用一個sql完成select
select 自定義
from A left join B on A.id = B.id
where B.id is null
union all
select 自定義
from B left join A on A.id = B.id
where A.id is null
若是返回結果爲空則表示 兩邊數據一致nio