how can i save the file after SELECT ... INTO OUTFILE 'result.csv'

cranberies picture cranberies · Nov 29, 2010 · Viewed 10.8k times · Source

i use this query to dump table into csv file :

$sql = "SELECT * 
        INTO OUTFILE 'result.csv'
        FIELDS TERMINATED BY ';'
        FROM tableName";

i get a result.csv file in the db folder of mysql

how can i save it at root of my site ?

Answer

codaddict picture codaddict · Nov 29, 2010

In place of result.csv provide the path where you want it to be saved:

$sql = "SELECT * 
        INTO OUTFILE '/path/to/your/site/result.csv'
        FIELDS TERMINATED BY ';'
        FROM tableName";