write results of sql query to a file in mysql

前端 未结 5 987
心在旅途
心在旅途 2021-02-01 01:44

I\'m trying to write the results of a query to a file using mysql. I\'ve seen some information on the outfile construct in a few places but it seems that this only writes the fi

5条回答
  •  时光说笑
    2021-02-01 01:59

    You could try this, if you want to write MySQL query result in a file.

    This example write the MySQL query result into a csv file with comma separated format

    SELECT id,name,email FROM customers
    INTO OUTFILE '/tmp/customers.csv'
    FIELDS TERMINATED BY ','
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    

提交回复
热议问题