【发布时间】:2010-05-17 10:01:06
【问题描述】:
嘿,我在 windows 5.1.39-community 和 linux 5.1.39-log 上有 2 个版本的 mysql 我执行一个查询:
SELECT `o`.`idOffer`,
`o`.`offer_date`,
`p`.`factory`,
`c`.`short` AS `company`,
`s`.`name` AS `subcategory`,
`ct`.`name` AS `category`,
count( (select count(1) from product where idProduct=idOffer group by idOffer) ) as b
FROM `Offer` AS `o`
LEFT JOIN `Product` AS `p` ON o.idOffer = p.idOffer
LEFT JOIN `company` AS `c` ON o.company = c.id
LEFT JOIN `Subcategory` AS `s` ON s.idSubcategory = o.idSubcategory
LEFT JOIN `Category` AS `ct` ON ct.idCategory = s.idCategory
WHERE (o.idOffer = p.idOffer) GROUP BY `o`.`idOffer`
在 windows 上它可以正常工作,但在 linux 上它说:
ERROR 1242 (21000): Subquery returns more than 1 row
有没有办法让它在没有任何 mysql 更新/降级的情况下在 linux 上运行?
【问题讨论】:
-
子查询中的
group by idOffer子句不是因为where idProduct=idOffer而多余吗?只需在子查询中不使用 group by 即可尝试。 -
它有效,谢谢,不会考虑这个。再次感谢:)