[英]Error with MySQL syntax in java
PreparedStatement sql1 = connection.prepareStatement("UPDATE `bantable` " +
"SET reason=?, admin=?, started=?, time=?, ends=?, banned=?, datetimes=? " +
"WHERE DATE_SUB(`datetimes`, NOW())<=0 AND player=?;");
com.mysql.jdbc.exceptions.jdbc4.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 'NOW())<=0 AND player='Juustoast''
at line 1
Why does it print that error? 为什么会显示该错误?
NOW()
is just a datetime, so if datetimes
also is you can just compare them using normal operators NOW()
只是一个日期时间,因此,如果datetimes
也是,则可以使用常规运算符进行比较
WHERE datetimes < NOW()
If datetimes
is not a datetime
, date
, or timestamp
you will have to convert it. 如果datetimes
不是 datetime
, date
或timestamp
,则必须对其进行转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.