mysql query return excel file
#Before exectue query in sql run following command:
sudo chmod 755 -R /var/lib/mysql/
#run query in mysql
SELECT ... FROM ... WHERE ...
INTO OUTFILE 'file.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';
#Then Open Excel and click on Data tab,
#Click the From Text/CSV button,
#Navigate to the location of the exported .csv file and click Import
#Choose appropriate delimiter "comma"and click Transform Data
#Update column name, Close & Load.