php - 我的数据未在数据库中获取

标签 php mysql sql database group-by

我的问题是这些查询总是在我的本地服务器上运行,但不是在线运行。

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

在线服务器显示在下面这一行:

1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'gloriast_gloria.addtocart_2.order_number'; this is incompatible with sql_mode=only_full_group_by

enter image description here

最佳答案

在 MYSQL 引发的文本异常中你有答案:-)

this is incompatible with sql_mode=only_full_group_by

在您的本地数据库中,您设置了不同的模式。请参阅 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

关于php - 我的数据未在数据库中获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51318663/

相关文章:

php - 使用ajax和json处理多个数据库行

php - 如何表达 symfony 路由占位符不等于某个值

php - 如何使用preg_replace和htaccess修改url?

PHP PDO - 我该怎么做

php - 避免跨越重量范围 BETWEEN,两列?数据库

sql - 存储纯文本(除 HTML 数据外)是否有利于提高可搜索性?

php - 奇怪的 MySQL 通配符行为

php - 如何解析具有精确字符串长度的字符串?

sql - 在给定数据库的所有存储过程中搜索关键字?

mysql(innodb)外键约束问题