How can I extract a MySQL query result in CSV format?

Hello Will

I am running a MySQL query from the linux command line and I need to output the results in CSV format. I need an efficient way to extract that information with the from MySQL that is properly escapes any quotes that exist in the data.

Thank you

Jim from Washington DC

One thought on “How can I extract a MySQL query result in CSV format?

  1. Hello Jim,

    There is a simple and efficient way to extract the information from MySQL to CSV format. You just need to build your query properly. Below is an example of a query that will extract the information in CSV format.

    SELECT *
    FROM people
    INTO OUTFILE '/tmp/people.csv'
    FIELDS TERMINATED BY ','
    ENCLOSED BY '"'
    LINES TERMINATED BY 'n'

     

Comments are closed.