Mysql Command of the day Source

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---
11
12I thought this one was worth blogging. To save the output of an SQL query in a file simply do this:
13
14```
15SELECT *
16FROM table
17INTO OUTFILE "/tmp/filename.txt"
18```
19
20Produces a tab delimited file with the outputs of the query - pretty simple...
21
22```
23
24```
25
26```
27SELECT order_id,product_name,qty
28    FROM orders
29    INTO OUTFILE '/tmp/orders.csv'
30        FIELDS TERMINATED BY ','
31        ENCLOSED BY '"'
32        LINES TERMINATED BY '\n'
33```
34
35```
36
37```
38Will enclose the fields in quotes separated with a comma.
39
40
41