1

任何人都可以在这里看到错误。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'
4

4 回答 4

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'
于 2013-04-10T18:15:02.760 回答
5

您的 sql中没有FROM子句。

select product.*, category.*, store.* from product 
inner join ....
于 2013-04-10T18:15:19.507 回答
2

You seem to be mixing up the purpose of your where and on clauses.

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'
于 2013-04-10T18:18:32.213 回答
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
于 2013-04-10T18:23:51.210 回答