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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query output to csv file 1

Status
Not open for further replies.

shamrox

Programmer
Sep 27, 2001
81
US
I'm using php/mysql for a website. One page the user can create a query to pull data from the database, but I want it to automatically save the data to a csv file. Is this possible, and how?

 
It certainly is possible:
[tt]
SELECT fieldlist
INTO OUTFILE 'filepath'
FROM ...
WHERE ...
[/tt]
This will output to a file using tab delimiters. If you want to use the traditional CSV delimiters of quotes and commas, you can use:[tt]
INTO OUTFILE 'filepath'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top