简体   繁体   English

MySQL 使用相同的查询在 PHP 和 PHPMyadmin 上返回不同的结果

[英]MySQL returning Different results on PHP and PHPMyadmin using same Query

1- Here is simple php code retrieving MySQL rows 1-这里是简单的 php 代码检索 MySQL 行

在此处输入图像描述

2- Here is return result of above code with query. 2-这是上述代码的查询返回结果。 在此处输入图像描述

3- But when I copy paste same query in phpmyadmin 100% sure on same database It returns different result. 3-但是当我在 phpmyadmin 中复制粘贴相同的查询时100% 肯定在同一个数据库上它返回不同的结果。 See screenshot below;见下面的截图; 在此处输入图像描述

This blow up my mind, trying to figure out since two days but didn't find any solution.这让我大吃一惊,两天以来一直想弄清楚但没有找到任何解决方案。 What could be possible issue?可能是什么问题?

Your query is an aggregation query that has group by t.destination .您的查询是group by t.destination的聚合查询。

However, it selects a bunch of other columns that are not arguments to aggregation functions.但是,它会选择一堆不是 arguments 的其他列来聚合函数。 There is no evidence that they are functionally dependent on t.destination either.也没有证据表明它们在功能上依赖于t.destination

Happily, such sloppiness generates a syntax error on most databases.令人高兴的是,这种草率会在大多数数据库上产生语法错误。 Happily, it generates a syntax error in the more recent versions of MySQL (using the default settings).令人高兴的是,它在较新版本的 MySQL(使用默认设置)中生成语法错误。 Unhappily.不高兴。 some people write such queries on older versions of MySQL (or change the flag that controls this).有些人在旧版本的 MySQL 上编写此类查询(或更改控制它的标志)。 . . . . and then wonder why the code doesn't work as expected.然后想知道为什么代码不能按预期工作。

The extra values come from an indeterminate matching row within each group.额外的值来自每个组中的不确定匹配行。 Running the query at different times might result in different values for those "bare" columns.在不同时间运行查询可能会导致这些“裸”列的值不同。 Running with different settings (or different sources) also might also result in different results.使用不同的设置(或不同的来源)运行也可能导致不同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM