MariaDb不支持ANY_VALUE()函数 [英] MariaDb does not support ANY_VALUE() function

查看:73
本文介绍了MariaDb不支持ANY_VALUE()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到mysql db的laravel项目,当我更换服务器时,我的代码失败了,因为我的新服务器上有一个 Mariadb ,当我检查日志时,我意识到,MariaDb有一些不受支持的功能,即 ANY_VALUE()

I have a laravel project which is connected to mysql db, when I change my server, my codes got failed because my new server has a Mariadb, when I checked my logs, I have realised that, there is some unsupported function from MariaDb which is ANY_VALUE(),

如何根据MariaDb编辑我的SQL?

how can I edit my sql according to MariaDb ?

select(DB::raw('SUM(price) as price, SUM(price_now) as price_now, 
   ANY_VALUE(price_available) as price_available'),'adult_count')

错误日志

推荐答案

今天,您已经解决了该问题.但是明天,当您运行相同的查询时,您将得到一个不同的错误.

For today, you have solved the problem. But tomorrow, when you run the same query, you will get a different error.

在旧版本的MySQL或MariaDB中,您将获得任何值". price_available 而不是 GROUPing BY 时使用.这实际上是在不良做法"之间的某个地方.和违反标准".相对最近,MariaDB,然后是后来的MySQL,切换到仅完整分组依据".那时, ANY_VALUE()开始出现在MySQL中,但显然MariaDB放弃了.

In older versions of MySQL or MariaDB, you would get "any value" for price_available when not GROUPing BY it. That was effectively somewhere between "bad practice" and a "standards violation". Relatively recently, MariaDB, then later MySQL, switched to "only full group by". At that time, ANY_VALUE() came into existence for MySQL, but apparently MariaDB dropped the ball.

对于旧版本和新版本均应安全的旧解决方法是使用 MIN(price_available)或其他一些汇总函数.(如果该列可能具有 NULL ,则各种聚合可能会也可能不会以您喜欢的方式处理 NULL .)

The old workaround, which should be safe for both old and new versions is to use MIN(price_available) or some other aggregate function. (If the column might have NULL, the various aggregates might or might not handle NULL the way you prefer.)

另请参见 ONLY_FULL_GROUP_BY 设置.

这篇关于MariaDb不支持ANY_VALUE()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆