Before, we were using mysql for our database but when we migrated to postgresql we encountered this problem.
SQLSTATE[42803]: Grouping error: 7 ERROR: column "table.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT COUNT(*) FROM (SELECT * FROM (SELECT * FROM "kv_firmw...
^
The SQL being executed was: SELECT COUNT(*) FROM (SELECT * FROM (SELECT * FROM "kv_firmware_release" ORDER BY "id" DESC) "table" GROUP BY "filename") "c"
I have this code in Yii2 search model.
$subquery = new Query;
$subquery->select(['*']);
$subquery->from('kv_firmware_release')->orderBy('id DESC');
$query = new Query;
$query->select(['*']);
$query->from(['table' => $subquery])->groupBy('filename');
$query->limit(5);
This is my first time to use Psql. It works fine before, but now it is giving me the error. How can I fix this in Yii2?