Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active April 14, 2016 10:28
Show Gist options
  • Save kurozumi/ff8786fb9c9000d9014d9509c460dfb5 to your computer and use it in GitHub Desktop.
Save kurozumi/ff8786fb9c9000d9014d9509c460dfb5 to your computer and use it in GitHub Desktop.
【MySQL】2つのテーブルを比較して重複していないデータを抽出してCSVファイルに保存する方法
SELECT
tbl1.item
FROM
tbl1
WHERE
NOT EXISTS (
SELECT
tbl2.item
FROM
tbl2
WHERE
tbl2.item = tbl1.item
)
INTO OUTFILE '/tmp/item.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment