select * from tables where to_char(a.creationdate,'yyyy-mm-dd') between '2008-01-01' and '2008-07-31'
感觉beteen应该是用来比较有大小的字段,难道这个是比较ASCII码?这样的句话查出来的结果是满足createiondate在'2008-01-01' 到'2008-07-31'
之间数据吗?晕了。
...全文
19726打赏收藏
between函数可以用于字符串的比较吗?
select * from tables where to_char(a.creationdate,'yyyy-mm-dd') between '2008-01-01' and '2008-07-31' 感觉beteen应该是用来比较有大小的字段,难道这个是比较ASCII码?这样的句话查出来的结果是满足createiondate在'2008-01-01' 到'2008-07-31' 之间数据吗?晕了。
[Quote=引用 2 楼 NetShape 的回复:]
是的,我一直觉的这样写select * from tables where creationdate between to_date('2008-01-01','yyyy-mm-dd') and to_date('2008-07-31','yyyy-mm-dd')
可是今天有一个开发,这样写
select * from tables where to_char(a.creationdate,'yyyy-mm-dd') between '2008-01-01' and '2008-07-31'
这两句是相等的吗?性能上会有差异吗?总感觉用to_char挺奇怪的。可能是我见的少了。有哪位大哥可以解答下,这两种方式是不是相…
[/Quote]
是的,我一直觉的这样写select * from tables where creationdate between to_date('2008-01-01','yyyy-mm-dd') and to_date('2008-07-31','yyyy-mm-dd')
可是今天有一个开发,这样写
select * from tables where to_char(a.creationdate,'yyyy-mm-dd') between '2008-01-01' and '2008-07-31'
这两句是相等的吗?性能上会有差异吗?总感觉用to_char挺奇怪的。可能是我见的少了。有哪位大哥可以解答下,这两种方式是不是相等的。creationdate是date类型的。