How can i rename the filename with a concat function ? i want my filename with a date,, can anyone help me on this.
SET @OUTFILE = CONCAT( CONCAT('/xampp/htdocs/mysite/reports-', NOW()), '.csv');
SELECT * FROM `tbl_user` INTO OUTFILE @OUTFILE FIELDS TERMINATED BY ','ENCLOSED BY '"' LINES TERMINATED BY '\n'
you can do something like:
SET @sql_text =
CONCAT (
"SELECT * FROM `tbl_user` into outfile '/xampp/htdocs/mysite/reports-"
, DATE_FORMAT( NOW(), '%Y%m%d')
, ".csv'"
);
PREPARE s1 FROM @sql_text;
EXECUTE s1;
DROP PREPARE s1;
You should use prepared statements. Build a query string, then execute it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With