How to get text file or CSV file from MySQL query results

MySQL provides a option to save your query date in CSV or txt format.

SELECT id, productName FROM product WHERE id != ” INTO OUTFILE ‘product.csv’ FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’