How to export MySQL data directly into CSV

It is possible to export result of a MySql query directly into a CSV file.

Here is an example

SELECT n.title AS title, CONCAT('https://example.com/', a.alias) AS url INTO OUTFILE '/tmp/example_result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
FROM  node n
INNER JOIN taxonomy_index AS ti ON ti.nid = n.nid
INNER JOIN url_alias AS a ON CONCAT('node/', n.nid ) = a.source
WHERE  (n.type = 'article' AND n.status = 1 AND ti.tid = 1894 );

*Before running the query, make sure the location you want to store your result file has write permissions by MySQL.

********************************** ************************* ************************ **************** ****************** *********** ************** ************* ************ *************