How to export a mysql CLI query into a csv file
if you are trying to export your query into a csv file to share it or just analyze any data, you can perform the following CLI command:
mysql -h'<host>' -u'<user>' -p'<password>' '<dbname>' -e '
select * from table
where <condition>' | tr '\t' ',' > mycsvfile.csv
Hope it helps.