gpt4 book ai didi

mysql - 这个 MySQL 查询有什么问题 (#1064)?

转载 作者:太空宇宙 更新时间:2023-11-03 12:36:25 25 4
gpt4 key购买 nike

谁能告诉我这个 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 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN item_images ON items.id=item_images.item_id' at line 1

最佳答案

你在错误的位置有 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

关于mysql - 这个 MySQL 查询有什么问题 (#1064)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12904828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com