输出mysql中的问题 [英] Problem in the output mysql
问题描述
你好
带有数据库的退出代码mysql
hello
With an exit code of the database mysql
$sql = "select * from insertdatafot where year='90' and month between '1' and '2' INTO OUTFILE 'd:\\$name.text' FIELDS TERMINATED BY ',' LINES TERMINATED BY ',' ";
我用这段代码制作的桌子
The table I made with this code
CREATE TABLE `insertdatafot` (
id INT NOT NULL AUTO_INCREMENT,
`city` VARCHAR(10) NOT NULL,
`jms` int(15),
`jzs` int(15) ,
`mms` int(15) ,
`mzs` int(15) ,
`month` int(5) ,
`year` int(5) ,
PRIMARY KEY(id)
)ENGINE = MYISAM CHARACTER SET utf8 ;
当我外出时,我的字段为空\ N
我是空的
例子
1,0,12,12,7,8,9,\ N,0,8,90,7,6,5,4,5,6,1,90,90,
否则
1,0,12,12,7,8,9,,0,8,90,7,6,5,4,5,6,1,90,90,
帮助我
When I am out to my fields is null \ N
I am empty
example
1,0,12,12,7,8,9,\N,0,8,90,7,6,5,4,5,6,1,90,90,
To do otherwise
1,0,12,12,7,8,9,,0,8,90,7,6,5,4,5,6,1,90,90,
help me
推荐答案
sql = "
sql = "select * from insertdatafot where year='90' and month between '1' and '2' INTO OUTFILE 'd:\\
name.text' BY','";
name.text' FIELDS TERMINATED BY ',' LINES TERMINATED BY ',' ";
我用这段代码制作的桌子
The table I made with this code
CREATE TABLE `insertdatafot` (
id INT NOT NULL AUTO_INCREMENT,
`city` VARCHAR(10) NOT NULL,
`jms` int(15),
`jzs` int(15) ,
`mms` int(15) ,
`mzs` int(15) ,
`month` int(5) ,
`year` int(5) ,
PRIMARY KEY(id)
)ENGINE = MYISAM CHARACTER SET utf8 ;
当我外出时,我的字段为空\ N
我是空的
例子
1,0,12,12,7,8,9,\ N,0,8,90,7,6,5,4,5,6,1,90,90,
否则
1,0,12,12,7,8,9,,0,8,90,7,6,5,4,5,6,1,90,90,
帮帮我
When I am out to my fields is null \ N
I am empty
example
1,0,12,12,7,8,9,\N,0,8,90,7,6,5,4,5,6,1,90,90,
To do otherwise
1,0,12,12,7,8,9,,0,8,90,7,6,5,4,5,6,1,90,90,
help me
您应该更改您的select语句,并为所有可能具有空值的字段合并(field_name,'''').
示例:从insertdatafot中选择Coalesce(jzs,''''),其中year =''90'',月份在''1''和''2''之间INTO OUTFILE''d:\\
You should change your select statement and place coalesce(field_name,'''') for all fields with possible null values.
Example: select coalesce(jzs,'''') from insertdatafot where year=''90'' and month between ''1'' and ''2'' INTO OUTFILE ''d:\\
这篇关于输出mysql中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!