jsp数据库查询,
数据库里面有个字段time,文本类型,
比如12-1月 -10 10.51.09.687000 上午
比如1-11月 -10 10.51.09.687000 上午
记录的是处理时间,
1月12日上午10点多
11月1日上午10点多我想查询指定月份month的所有记录,下面的sql应该怎么写??String sql = "select * from table where time="month"";

解决方案 »

  1.   

    http://blog.csdn.net/ltolll/archive/2008/11/29/3409748.aspx
    lz 可以参考
      

  2.   

    String sql = "select * from table t where t.time=to_char(to_timestamp(t.time),'mm');
      

  3.   

    将time字段转换类型就可以了
    select * from table where time=DATE_FORMAT('time','yyyy-MM');
      

  4.   

    我的sql在oracle中是可以满足需求的,不知道你的数据库是什么。。
      

  5.   

    String sql = "select * from table t where to_char(to_timestamp(t.time),'mm')="你的月份"; 
     
      

  6.   

    select * from table where time like '%time'
      

  7.   

    time:'2010-01'
    select * from table where time like '%time' 
      

  8.   

    select * from table where time like '%[1][0-2]%' or time like '%[1-9]%' 
      

  9.   

    orcale用toDate()函数转换一下,不过这种方法不好,这样写死了并且在底层处理的,可以用Java中的日期处理函数处理,先把数据查询出来,然后用Java程序处理较好一点。