In Older Versions of MySQL:
SELECT customer_id,customer_name,customer_age FROM customer WHERE salary > 50000 INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
In Newer Versions of MySQL:
SELECT customer_id,customer_name,customer_age INTO OUTFILE '/var/lib/mysql-files/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; FROM customer WHERE salary > 50000