请帮我找错。我在SqlServer中检查了它,一切都很好。但NetBeans提供错误:“关键字”JOIN“»
附近的语法不正确String query = "SELECT Sale.date_sale, Cheque.quantity, Goods.price, Cheque.quantity*Goods.price" +
"FROM Sale JOIN Cheque ON Sale.id = Cheque.id_sale JOIN Goods ON Goods.id = Cheque.id_goods" +
"WHERE Sale.date_sale BETWEEN '2001-04-12' AND '2015-06-12' AND Goods.id = 1";
ResultSet rs = stmt.executeQuery(query);
答案 0 :(得分:1)
尝试在要连接的字符串的开头或结尾添加空格:
String query = "SELECT Sale.date_sale, Cheque.quantity, Goods.price, Cheque.quantity*Goods.price" +
" FROM Sale JOIN Cheque ON Sale.id = Cheque.id_sale JOIN Goods ON Goods.id = Cheque.id_goods" +
" WHERE Sale.date_sale BETWEEN '2001-04-12' AND '2015-06-12' AND Goods.id = 1";
答案 1 :(得分:0)
你需要在你连接的字符串的开头插入空格,否则你将会遇到错误的表达,例如“Cheque.quantity * Goods.priceFROM”和“Cheque.id_goodsWHERE”。