Export Mysql Table Data in csv format through single query

Import and Export database or tables is really an important factor of coding and it is most important thing for every programmer. So sometimes we write lots of code to export any table from database in csv format. I am also a PHP programmer so I know these things. I found a good solution to export any table from database in csv format. Here is a query.

SELECT * FROM tablename INTO OUTFILE '/filename.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n’

So you can now easily export and table in csv format using above query in your code.

Leave a Reply

Your email address will not be published. Required fields are marked *