Skip to content

Instantly share code, notes, and snippets.

@sunaot
Created July 27, 2012 19:14
Show Gist options
  • Save sunaot/3189917 to your computer and use it in GitHub Desktop.
Save sunaot/3189917 to your computer and use it in GitHub Desktop.
2 テーブルの差分を MySQL で。
select
'a dake' as type
, id
, ckey
from
table_a a
where not exists
(select 1 from table_b b where a.id <=> b.id and a.ckey <=> b.ckey)
union all
select
'b dake' as type
, id
, ckey
from
table_b b
where not exists
(select 1 from table_a a where b.id <=> a.id and b.ckey <=> a.ckey)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment