【发布时间】:2022-01-28 12:44:17
【问题描述】:
如何从表中选择最新的不同记录,最好使用 eloquent laravel 的查询构建器。
我试过这个查询没有成功。
Products::where('depart_id', $depart_id)
->distinct("serial_number")
->latest()
->where('serial_number', ""); // get one of the distinct products
【问题讨论】:
-
latest()方法根据created_at列对记录进行排序。 -
您遇到什么类型的错误?
标签: php sql laravel database eloquent