任何人都可以在这里看到错误。 PhpMyAdmin告诉我在where子句附近有错误。
SELECT product.*, category.*,store.*
WHERE
store.store_id = product.store_id AND
category.category_id = product.category_id
INNER JOIN store ON store.store_name = 'mens'
INNER JOIN category ON category.category_name = 'rings'
答案 0 :(得分:5)
INNER JOIN
属于FROM
子句,而不属于WHERE
子句。 FROM
子句完全缺失。
SELECT product.*, category.*, store.*
FROM product, category, store
WHERE store.store_id = product.store_id AND
category.category_id = product.category_id AND
store.store_name = 'mens' AND
category.category_name = 'rings'
答案 1 :(得分:5)
你的sql中没有FROM
子句。
select product.*, category.*, store.* from product
inner join ....
答案 2 :(得分:2)
您似乎混淆了where
和on
条款的目的。
SELECT product.*,category.*,store.*
From Product
INNER JOIN store on store.store_id = product.store_id
inner join category on category.category_id = product.category_id
where store.store_name= 'mens' and category.category_name = 'rings'
答案 3 :(得分:2)
Select查询中的每个主要子句必须按正确顺序排列。
订单是:
Select ... [Output fields and expressuions] -- Required
From ... [list of tables, with joins and join conditions] -- Required
Where [Predicates and filter conditions] -- Optional
Group By [list of fields/expressns to group results by] -- reqr'd for aggregate queries
Order By [List of fields and expressions to sort results by -- optional