I have a mysql query:
SELECT MAX(CAST(REPLACE(name,'test','') AS SIGNED)) FROM `accts` WHERE `name` LIKE 'test%';
If I run the query in the MySQL console it executes.
If I execute this query with mysqli_query in PHP
mysqli_query($connection, "SELECT max(cast(replace(name,'test','') as signed)) FROM accts WHERE name LIKE '$test%'")
it executes.
If I run it in laravel:
DB::connection('db')
->table('accts')
->select(DB::raw("max(cast(replace(name,'test','') as signed))"))
->where('name', 'like', "'$test%'")
->get();
It throws an error:
SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns (MIN(), MAX(), COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause (SQL: select max(cast(replace(name,'test','') as signed)) from `accts` where `name` like 'test%')
Does anybody have any idea what is happening? The error looks like it is coming from the server but the server has no problem with the query. Is there an issue with how laravel is executing the query?