以前的相关主题:Join in Query WHERE clause
我收到了这个错误:
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '.'.
我的SQL声明:
SELECT products.id, products.name products.extended_description, products.catalogid, products.image1, products.image2, products.stock, products.price, manufacturer.manufacturer, products.weight
FROM products
JOIN manufacturer ON (products.manufacturer = manufacturer.id)
JOIN product_category ON (product_category.catalogid = products.catalogid)
JOIN category ON (category.id = product_category.id)
WHERE category.category_name = ?;
这里有什么问题?我的陈述对我来说是正确的......
答案 0 :(得分:3)
您错过了products.name
和products.extended_description
之间的逗号。它认为products.extended_description是别名。如果它然后放在它周围。 [products.extended_description]
。否则请输入缺少的逗号。
SELECT products.id, products.name, products.extended_description, products.catalogid,
products.image1, products.image2, products.stock, products.price,
manufacturer.manufacturer, products.weight
FROM products
JOIN manufacturer ON (products.manufacturer = manufacturer.id)
JOIN product_category ON (product_category.catalogid = product.catalogid)
JOIN category ON (category.id = product_category.id)
WHERE category.category_name = ?;
答案 1 :(得分:2)
您忘记了products.name
应该是:
SELECT products.id, products.name, products.extended_description, ...