tags:

views:

24

answers:

1

hey, i have 2 version of mysql on windows 5.1.39-community and on linux 5.1.39-log i execute a query:

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`

on windows it works as it suppose, but on linux it says:

ERROR 1242 (21000): Subquery returns more than 1 row

is it any way to get it worked on linux without any mysql updates/downgrades ?

A: 

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.

DRapp