我有一sql语句:
select * from table1 where date(selltime) = '2008-12-01' 查询不到数据,但是用
select * from table1 where trim(date(selltime)) = '2008-12-01' 却能查询出来需要数据
有谁能告诉我原因。
环境:
linux redhat
mysql 5.0.45-community
select * from table1 where date(selltime) = '2008-12-01' 查询不到数据,但是用
select * from table1 where trim(date(selltime)) = '2008-12-01' 却能查询出来需要数据
有谁能告诉我原因。
环境:
linux redhat
mysql 5.0.45-community
null
2008-12-01
2008-12-02
2008-12-03
select * from table1 where date(ifnull(selltime,selltime,'2008-1-1')) = '2008-12-01'
select * from tt2 where date(ifnull(selltime,'2008-1-1')) = '2008-12-01'
select *,date(selltime),trim(date(selltime)) from tt2
看看结果就知道了
`id` int(11) NOT NULL,
`selltime` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
select * from table1 where date(selltime) = '2008-12-01'
可以查询出来数据。MYSQL 5.1.17