1

嘿,我在 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 上运行?

4

2 回答 2

0

Since your SQL "as b" columnResult is based specifically on a SQL, and the WHERE clause of the of the idOffer already qualifies and SHOULD be the same, I would remove the group by of this columnar element. I can only assume there might be some white-space data or other that is falsely getting included and "ID1" is different than "ID1 " is getting falsely interpretted.

于 2010-05-17T10:41:43.117 回答
0

不知道这是否与它有关,但是 Linux MySQL 表是区分大小写的,而 Windows 表不区分大小写(我怀疑是因为文件系统),无论如何,你有Product并且product这会导致一些问题。

不知道这是否真的是您问题中问题的原因,但它是一堵墙,您最终可能会撞到墙上,我认为应该提出来。

于 2011-07-13T03:12:26.437 回答