Skip to content

Instantly share code, notes, and snippets.

@malkafly
Forked from reyesyang/mysql_outfile.sql
Created June 1, 2018 12:56
Show Gist options
  • Save malkafly/658fe7de98d27b4983f8f7c21a276381 to your computer and use it in GitHub Desktop.
Save malkafly/658fe7de98d27b4983f8f7c21a276381 to your computer and use it in GitHub Desktop.
Export MySQL query result to CSV file
SELECT id, username, (total_point - spent_point) AS point
FROM users
ORDER BY point DESC
LIMIT 50
INTO OUTFILE '/tmp/bbs_points_top50.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment