meetpd
meetpd

Reputation: 9219

How to fetch data from MySQL database into Excel

How to fetch data from MySQL database table into Excel?

Upvotes: 2

Views: 26162

Answers (5)

M Gaidhane
M Gaidhane

Reputation: 531

Try out with

SELECT column1, column1, column1 from tablename INTO OUTFILE "path/CSV/tablename.xls" FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" <br>

refer http://dev.mysql.com/doc/refman/5.1/en/load-data.html

Upvotes: 2

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146430

I think the easiest way is ODBC. You can download the ODBC driver for MySQL (if you don't have it already). Then, once inside Excel, you can go to "Data-> Obtain external data" (the name and location of the menu items may vary) and pick or create a data source.

Upvotes: 1

Johan
Johan

Reputation: 76547

If your server is also your client machine you can do

select * from table1 into outfile 'c:/path/outfile.csv'

(Note the use of forward slashes even on Windows)

If your server is a remote machine, make sure your have the MySQL client software installed on the client machine and do:

mysql -e "SELECT * from table1" > file_name

You can then open the csv file in Excel.

Upvotes: 2

Quassnoi
Quassnoi

Reputation: 425341

  1. Install Connector/ODBC

  2. Create an ODBC DSN (Control Panel / Administration / ODBC if on Windows)

  3. Import data using Microsoft Query (Data / External Data / From Other Sources / Microsoft Query in Excel 2007)

Upvotes: 8

Teson
Teson

Reputation: 6736

odbc-query.

excel: /data/get external data...

Upvotes: 0

Related Questions