Last active
August 29, 2015 14:10
-
-
Save xxxkurosukexxx/3cd0a477e268f6db6aab to your computer and use it in GitHub Desktop.
テーブルの比較で、カラムの値を結合して比較 ref: http://qiita.com/xxxkurosukexxx/items/d760de028b609a0c1646
This file contains 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 | |
* | |
FROM | |
table_a | |
LEFT OUTER JOIN | |
table_b | |
ON | |
(a_item_id = b_item_no and a_code = concat(b_x, b_y, b_z)) | |
WHERE | |
b.item_no IS NULL; |
This file contains 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 | |
* | |
FROM | |
table_a | |
WHERE | |
NOT EXISTS ( | |
SELECT | |
NULL | |
FROM | |
table_b | |
WHERE | |
a_item_id = b_item_no | |
and a_code = concat(b_x, b_y, b_z) | |
) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment