MySQL不同版本其他结果

发布于 2024-09-01 15:20:25 字数 846 浏览 2 评论 0原文

嘿,我在 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

有什么办法让它在Linux上工作而不需要任何mysql更新/降级?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南风起 2024-09-08 15:20:27

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

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

No idea if this has anything to do with it, but Linux MySQL tables are case sensitive while Windows tables are not (because of the filesystem, I suspect), anyway, you have Product and product and that will cause some problems.

Don't know if it really is the cause of the problem in your question, but it is a wall you may end up flying smack into and I thought it should be brought up.

落在眉间の轻吻 2024-09-08 15:20:26

由于您的 SQL“as b”columnResult 专门基于 SQL,并且 idOffer 的 WHERE 子句已经符合条件并且应该相同,因此我将删除此列元素的分组依据。我只能假设可能存在一些空白数据或其他被错误地包含在内的数据,并且“ID1”与“ID1”不同被错误地解释。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文