1---2title: 'Mysql Command of the day'3date: '2007-05-03'4published_at: '2007-05-03T11:36:00.000+10:00'5tags: []6author: 'Gavin Jackson'7excerpt: 'I thought this one was worth blogging. To save the output of an SQL query in a file simply do this: SELECT * FROM table INTO OUTFILE "/tmp/filename.txt" Produces a tab delimited file with the outputs...'8updated_at: '2007-05-03T13:58:52.495+10:00'9legacy_url: 'http://www.gavinj.net/2007/05/mysql-command-of-day.html'10---1112I thought this one was worth blogging. To save the output of an SQL query in a file simply do this:1314```15SELECT *16FROM table17INTO OUTFILE "/tmp/filename.txt"18```1920Produces a tab delimited file with the outputs of the query - pretty simple...2122```2324```2526```27SELECT order_id,product_name,qty28 FROM orders29 INTO OUTFILE '/tmp/orders.csv'30 FIELDS TERMINATED BY ','31 ENCLOSED BY '"'32 LINES TERMINATED BY '\n'33```3435```3637```38Will enclose the fields in quotes separated with a comma.394041