#小李子9479#
有如下的数据结构 ,st_dl tinyint(4),想从中读取不等于1的数据
于是写了一个sql语句
select * from tbname where st_dl<>1
返回数据为0。
修改一下
select * from tbname where IFNULL(st_dl,0)<>1
正确返回数据
IFNULL(st_dl,0)
意思是,如果st_dl值为空或者是null,则返回0,即第2个参数。如果不是空值或NULL,则正常返回。
#小李子9479#
有如下的数据结构 ,st_dl tinyint(4),想从中读取不等于1的数据
于是写了一个sql语句
select * from tbname where st_dl<>1
返回数据为0。
修改一下
select * from tbname where IFNULL(st_dl,0)<>1
正确返回数据
IFNULL(st_dl,0)
意思是,如果st_dl值为空或者是null,则返回0,即第2个参数。如果不是空值或NULL,则正常返回。