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
+ 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
+ "'" + new Timestamp(System.currentTimeMillis()) + "' " + ">="
+ "(select max(time) from 表)";
上面只是两处语法上的错误。建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
直接用mysql本身的系统时间来判断就行了吧?
为什么还要用java里面进行系统时间判断呢?
time字段是abc表的吗??
时间你要做为参数传递给sql,不要直接连接字符串
好用,高手啊!呵呵
可以告诉我current_timestamp()是什么东东么?
+ new Timestamp(System.currentTimeMillis()) + "' " + ">="
+ "(select time from 表)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();