Skip to content

Instantly share code, notes, and snippets.

@xxxkurosukexxx
Last active August 29, 2015 14:10
Show Gist options
  • Save xxxkurosukexxx/3cd0a477e268f6db6aab to your computer and use it in GitHub Desktop.
Save xxxkurosukexxx/3cd0a477e268f6db6aab to your computer and use it in GitHub Desktop.
テーブルの比較で、カラムの値を結合して比較 ref: http://qiita.com/xxxkurosukexxx/items/d760de028b609a0c1646
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;
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