-3

I have been looking everywhere for a way to do this.

There are a lot of people that have asked the questions but when I try myself I can't seem to get it to work.

Often I get the format correct but it inputs the information into a new page instead of saving it.

I did manage to get one to work for Google Chrome but when I ran it in internet explorer it didn't work.

I have a table being created from a MYSQL query and i would like the table to be able to be saved as a CSV.

Could anyone help me out?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user2403705
  • 43
  • 2
  • 9

1 Answers1

2

You can try to use INTO OUTFILE clause:

SELECT col1, col2, ...
  INTO OUTFILE '/path/to/your/file.csv'
       FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
       LINES TERMINATED BY '\n'
   FROM tablename 
  WHERE ...
peterm
  • 91,357
  • 15
  • 148
  • 157
  • Some caveats: This file is created on the MySQL server, not on the client, and secondly, on some systems with a more robust `/tmp` filesystem the file might end up in `/tmp/systemd-private-XXXXX` where `XXXXX` is some random letters. – tadman Jun 28 '13 at 05:09