0

上一个相关主题:加入查询 WHERE 子句

我收到此错误:

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 = ?;

我在这里有什么问题?我的陈述在我看来是正确的......

4

2 回答 2

3

products.name您在and之间缺少逗号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 = ?;
于 2013-08-06T22:34:05.513 回答
2

你忘记了后面的逗号products.name

应该:

SELECT products.id, products.name, products.extended_description, ...
于 2013-08-06T22:32:58.347 回答