Home > Database > Mysql Tutorial > MYSQL5.1 WINDOWS环境下导出查询数据到EXCEL文件_MySQL

MYSQL5.1 WINDOWS环境下导出查询数据到EXCEL文件_MySQL

WBOY
Release: 2016-06-01 13:45:50
Original
1106 people have browsed it

bitsCN.com

今天做一个多表的联合查询,用phpmyadmin不支持导出,于是找到下面的方法,不错!

mysql查询出来的记录,导出到EXCEL文件,直接做报表输出。

测试环境WINDOWS XP,OFFICE 2003,MYSQL 5.1.45
1:创建一个测试表,3个字段,其中2个中文字段,用来做演示使用 mysql> create table tt(a int(11) not null,b varchar(30),c varchar(30));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into tt values(1,'北京','北京大学'),(2,'上海','上海大学'),(3,'深圳','深圳大学');
Query OK, 3 rows affected

Records: 3 Duplicates: 0 Warnings: 0
 

2:导出到EXCEL文件,用OUTFILE方法,下面2种方法的效果是一样的

mysql> select b,c from tt into outfile 'c:/xls_tt.xls';
Query OK, 3 rows affected (0.00 sec)

mysql> select b,c into outfile 'c:/xlstt.xls' from tt;
Query OK, 3 rows affected (0.00 sec)
 

3:到C盘下找到导出的XLS文件,发现都是乱码,如


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template