String sql = "update abc表 set dengji=dengji+1 where" + " "
+ new Timestamp(System.currentTimeMillis()) + " " + ">="
+ "(select time from 表)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();我要根据当前时间大于abc表时间作为条件,使表abc的字段等级加一
可提示这样的错误:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '11:25:48.609 >=(select time from abc)' at line 1

解决方案 »

  1.   

    String sql = "update abc表 set dengji=dengji+1 where" + " "
    + "'" + new Timestamp(System.currentTimeMillis()) + "' " + ">="
    + "(select max(time) from 表)";
    上面只是两处语法上的错误。建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
      

  2.   

    update abc表 set dengji=dengji+1 where current_timestamp()>time
      

  3.   

    我要根据当前时间大于abc表时间作为条件,使表abc的字段等级加一---------------------------------
    直接用mysql本身的系统时间来判断就行了吧?
    为什么还要用java里面进行系统时间判断呢?
      

  4.   

    这个问题
    time字段是abc表的吗??
    时间你要做为参数传递给sql,不要直接连接字符串
      

  5.   


    好用,高手啊!呵呵
    可以告诉我current_timestamp()是什么东东么?
      

  6.   

    CURRENT_TIMESTAMP()、 CURRENT_TIME()、 CURRENT_DATE()以及FROM_UNIXTIME()函数返回连接当前时区内的值,这个值可用作time_zone系统变量的值。
      

  7.   

    楼主啊,你的错误很简单,只要你把你的sql语句打出来,就一切都清楚了。你可以这样写,不过不知道是不是你的愿意。String sql = "update abc表 set dengji=dengji+1 where" + " '" 
    + new Timestamp(System.currentTimeMillis()) + "' " + ">=" 
    + "(select time from 表)"; 
    PreparedStatement pstmt = conn.prepareStatement(sql); 
    pstmt.executeUpdate(); 
      

  8.   

     2楼的方法同时要注意你表里的字段time存的是什么格式 是UNIX时间戳还是'2009-03-03 22:22:22' 这样的。