Update a file using mysql

303 Views Asked by At

I've a database and im trying to export the data from a table to a .csv file so that i can import the data as contact data. I can create the file and write to it using this syntax:

SELECT E_Name, Email INTO OUTFILE '/xampp/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM email WHERE 1

the problem is when i run this a 2nd time, i get an error that the file already exists. (im aware it exists as i've previously ran the query and it created it) What i would like to happen is to either, check the information is there from before and add the new information, or simpler again, overwrite the original file with the updated version.

could anyone throw some information on how to do this?

Thanks in advance,

Andrew

///////////edit\\\\\\\\\\\\\\

okay, decided to go for the timestamp method as ^^^^ cannot really be done. however im now running into an error for this aswell :$

CONCAT(SELECT E_Name, Email INTO OUTFILE '/xampp/tmp/Sample', DATE_FORMAT(now(),    '%d%m%Y'), '.csv')
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM email WHERE 1

Can anyone help me with this concat problem? unexpected IDENT_QUOTED

0

There are 0 best solutions below