If you already have a table and want to export it to an Excel file, then you can simply use below script and apply it as query :
SELECT * FROM tablename
INTO OUTFILE ‘C:/myfile.csv’ FIELDS TERMINATED BY ‘,’
ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’
Above query will produce an excel file named myfile.csv in C:\ Drive. Simply replace the first row with your desired sql query.
*) Notes: if you want to use dynamic file name instead of myfile.csv, then you should read this article.
Anyway, did you notice inside your .csv file there is no column header?, to make your exported csv file is human readable it is better to put column header inside, read the tutorial here.