Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concatenate in SQL query

Status
Not open for further replies.

DANDARSMASH

Programmer
May 17, 2013
17
0
0
US
Hello. I'm making a routine to run daily in SQL Workbench. I want the exported file to have curdate() added to the name for organizational purposes.

SQL:
SELECT
  d.emailaddress,
  d.fullname,
  d.address,
  d.city,
  d.state,
  d.zip,
  d.makepayabletoname,
  d.makepayabletoaddress,
  d.makepayabletocity,
  d.makepayabletostate,
  d.makepayabletozip,
  p.filenumber,
  p.paymentstatus,
  p.paymentamount,
  p.paymentdate
INTO OUTFILE '/tmp/' CURDATE();.'.csv'
FIELDS TERMINATED BY  ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '/\n'
FROM payments p
JOIN dbase d
ON p.filenumber = d.filenumber
WHERE p.paymentstatus = 'PENDING'
AND p.paymentdate = CURDATE();

The trouble line is: INTO OUTFILE '/tmp/' CURDATE();.'letters.csv' I want it to output to /tmp/2013-06-11letters.csv but I can't figure out how to concatenate.

URL]


"Any sufficiently advanced technology is indistinguishable from magic" [Arthur C. Clark]</td></tr></table>
 
As an independent query, the following works fine. It does not work when i plug it into my query in the previous post.

SQL:
SELECT
  CONCAT('/tmp/',DATE_FORMAT(curdate(), '%Y-%m-%d'),'letters.csv') AS your_date;

URL]


"Any sufficiently advanced technology is indistinguishable from magic" [Arthur C. Clark]</td></tr></table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top