简体   繁体   English

我的数据不在数据库中获取

[英]my data is not fetch in db

My problem is that these query always run on my local server but not don't run online. 我的问题是这些查询始终在我的本地服务器上运行,但不在线运行。

SELECT order_number, max(cart_datetime) maxdate, sum(cart_total), cart_u_id
FROM addtocart_2
WHERE cart_u_id ='$_SESSION[UserId]'
GROUP BY cart_datetime desc limit 1

Online server showing on this line below: 在线服务器显示在下面的此行中:

1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'gloriast_gloria.addtocart_2.order_number'; 1140-在没有GROUP BY的聚合查询中,SELECT列表的表达式#1包含非聚合列'gloriast_gloria.addtocart_2.order_number'; this is incompatible with sql_mode=only_full_group_by 这与sql_mode = only_full_group_by不兼容

在此处输入图片说明

In the text exception raised by MYSQL you have the answer :-) 在MYSQL引发的文本异常中,您可以找到答案:-)

this is incompatible with sql_mode=only_full_group_by 这与sql_mode = only_full_group_by不兼容

In your local DB, you have set different mode. 在本地数据库中,您设置了不同的模式。 Please refer to MySQL documentation to change that: https://dev.mysql.com/doc/refman/8.0/en/group-by-handling.html https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html 请参考MySQL文档进行更改: https : //dev.mysql.com/doc/refman/8.0/en/group-by-handling.html https://dev.mysql.com/doc/refman/8.0/ EN / SQL-mode.html

It seems like your server's mysql has ONLY_FULL_GROUP_BY enabled. 似乎您服务器的mysql已启用ONLY_FULL_GROUP_BY

You can disable it by running the following query in your server. 您可以通过在服务器中运行以下查询来禁用它。

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Then your query should work. 然后您的查询应该工作。 If you want to know why it happens, refer to the mysql documentation. 如果您想知道为什么会发生,请参考mysql文档。

https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html

It explains how and why this happens and how to solve this :) 它解释了这种情况的发生方式和原因以及解决方法:)

Hope it helps. 希望能帮助到你。

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

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