我的数据库中有一个表aaa,有三条数据:
post_id     login_time
-----------------------
0101        2007-8-4 
0202        2006-12-22 上
0303        2006-1-1 ?我想查出第一条数据,我的sql这样写:
select * from tb_sm_loginsess where login_time = to_date ('200-8-4','yy-mm-dd');查不出数据。
第二条和第三条应该怎么查出?谢谢

解决方案 »

  1.   

    select * from tb_sm_loginsess where login_time = to_date ( '2007-8-4 ', 'yyyy_mm_dd ');
    你的年规定的部队应该是4位的yyyy
      

  2.   

    select * from tb_sm_loginsess where login_time = to_date ( '2007-8-4 ', 'yyyy-mm-dd ');
    最好是把年设为四位,不然有可能涉及到两千年问题,如果觉得不错,期待加分
      

  3.   

    select * from tb_sm_loginsess where login_time = to_date ( '2007-8-4 ', 'yyyy-mm-dd ');
      

  4.   

    to_date ( '200-8-4 ', 'yy-mm-dd ')中的时间写错了吧。改成to_date ( '2007-8-4 ', 'yy-mm-dd ')
      

  5.   

    select * from tb_sm_loginsess where to_date(login_time,'yyyy-mm-dd') = to_date ( '200-8-4 ', 'yyyy-mm-dd ');