0

知道为什么要查询

SELECT 
  m.* 
FROM 
  products_description pd, 
  products p 
  left join manufacturers m on p.manufacturers_id = m.manufacturers_id,
  products_to_categories p2c 
WHERE 
  p.products_carrot = '0' and 
  p.products_status = '1' and 
  p.products_id = p2c.products_id and 
  pd.products_id = p2c.products_id and 
  pd.language_id = '4' and 
  p2c.categories_id = '42'
GROUP BY manufacturers_id 
ORDER BY COUNT(*)

可能会出现以下错误:

#1111- 无效使用组功能

在 MySQL 4.0.24 上而不是在 MySQL 5.0.51 上?

4

1 回答 1

1

自我回应。提到我想在 SELECT 子句中排序的列并将其别名化就可以了:

SELECT 
  m.*, COUNT(*) as cnt
FROM 
  products_description pd, 
  products p 
  left outer join manufacturers m on p.manufacturers_id = m.manufacturers_id,
  products_to_categories p2c 
WHERE 
  p.products_carrot = '0' and 
  p.products_status = '1' and 
  p.products_id = p2c.products_id and 
  pd.products_id = p2c.products_id and 
  pd.language_id = '4' and 
  p2c.categories_id = '42'
GROUP BY p.manufacturers_id 
ORDER BY cnt
于 2010-04-19T06:24:47.750 回答