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(),
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')
error log
For today, you have solved the problem. But tomorrow, when you run the same query, you will get a different error.
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.
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.)
See also the ONLY_FULL_GROUP_BY setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With