这个MySQL查询出了什么问题(#1064)?

时间:2012-10-15 22:16:07

标签: mysql

任何人都可以告诉我这个MySQL查询有什么问题

SELECT count(items.id) AS numrows 
FROM items, subcategories 
WHERE items.`base_school` = 'UNN' 
    AND items.subcategory = subcategories.id 
    AND subcategories.parent_category = 3 
JOIN `item_images` 
    ON items.id=`item_images`.`item_id`

它不断抛出这个错误:

  

#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法   在'加入item_images ON items.id = item_imagesitem_id'附近   1

1 个答案:

答案 0 :(得分:3)

你在错误的位置有WHERE子句,试试这个:

SELECT count(items.id) AS numrows 
FROM items
INNER JOIN subcategories 
    ON items.subcategory = subcategories.id 
INNER JOIN item_images 
    ON items.id=item_images.item_id
WHERE items.base_school = 'UNN' 
    AND subcategories.parent_category = 3