startD
是日期,endD
是日期,类型是字符串
String sqlStatement = "SELECT Booking.* FROM Booking INNER JOIN Room USING (RoomID) BETWEEN " + startD + ", " + endD+ " AND RoomSize = " + type;
这是我的错误:
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 'BETWEEN 2016-03-01, 2016-03-01 AND RoomSize = Medium' at line 1
答案 0 :(得分:0)
请参阅手册Between Clause
在条款
之间用AND替换答案 1 :(得分:0)
SQL语句不正确,如果是:String sqlStatement =“SELECT Booking。* FROM Booking INNER JOIN Room USING(RoomID)WHERE someDateColumn BETWEEN”+ startD +“AND”+ endD +“AND RoomSize =”+ type ;
答案 2 :(得分:0)
语法错误:
尝试以下方法:
String sqlStatement = "SELECT Booking.* FROM Booking INNER JOIN Room USING (RoomID) WHERE BETWEEN " + startD + " AND " + endD+ " AND RoomSize = " + type;
您缺少WHERE子句,而且,当您使用BETWEEN关键字提供范围时,您缺少AND(您已添加逗号)。