任何人都可以告诉我这个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_images
。item_id
'附近 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