【发布时间】:2018-04-05 04:17:54
【问题描述】:
没有groupBy 的行数相同。
$authors = AuthorMask::where('company_id', $user->company_id)
->groupBy('id', 'author_id')
->orderBy('created_at', 'desc')
->paginate(5);
如果我使用这个:
$authors = AuthorMask::where('company_id', $user->company_id)
->groupBy('author_id')
->orderBy('created_at', 'desc')
->paginate(5);
我收到一个错误。
SQLSTATE[42803]:分组错误:7 错误:列“author_masks.id” 必须出现在 GROUP BY 子句中或在聚合函数中使用 LINE 1: select * from "author_masks" where "company_id" = $1 group b... ^ (SQL: select * from "author_masks" where "company_id" = 1 group by "author_id" order by "created_at" desc limit 5 offset 0)
【问题讨论】:
标签: php sql postgresql laravel