SQL查询里面比较的有关问题

SQL查询里面比较的问题某个表里面有begindate、enddate两个字段(开始日期和结束日期),char(10)的格式(比如:

SQL查询里面比较的问题
某个表里面有begindate、enddate两个字段(开始日期和结束日期),char(10)的格式(比如:2010-04-29)。
我想写个SQL可以查出sysdate在begindate和enddate之间的记录。

sysdate可以直接和char(10)的类型比较吗?

比如:
select table1.* from table1
where tochar(sysdate,'yyyy-mm-dd') between begindate and enddate;

[解决办法]
select * 
from t
 where begindate >= to_char(trunc(sysdate), 'yyyy-mm-dd')
and enddate < to_char(trunc(sysdate) + 1, 'yyyy-mm-dd')


[解决办法]

SQL code
select table1.* from table1where to_char(sysdate,'yyyy-mm-dd')>=begindate and to_char(sysdate,'yyyy-mm-dd')<=enddate
[解决办法]
你的写法是可以的,如果begindate和enddate上有索引,
你的写法是用不上索引的(除非另建函数索引),所以最
好不要在字段上加函数计算,推荐1楼的写法。
[解决办法]
楼主的tochar应为to_char
[解决办法]
select table1.* from table1
where to_char(sysdate,'yyyy-mm-dd') between begindate and enddate;