Created
July 27, 2012 19:14
-
-
Save sunaot/3189917 to your computer and use it in GitHub Desktop.
2 テーブルの差分を MySQL で。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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