Exporting from an RDBMS always depends on the syntax of the specific RDBMS in question.  For MySQL, here is how to transform a SELECT statement into a CSV export:

SELECT a,b INTO OUTFILE '/tmp/result.csv'  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'  LINES TERMINATED BY 'n'  FROM test_table;

Reference: MySQL 5.0 Reference Manual