My case is the same as this : Sort data (order by) before group by in mysql
I try all answer there and I find the best answer from @Justin
The answer in mysql like this :
SELECT t1.*
FROM prd_data t1
WHERE t1.id = (SELECT t2.id
FROM prd_data t2
WHERE t2.sub_prd_id= t1.sub_prd_id
ORDER BY t2.created_at DESC
LIMIT 1)
I had try sql query and it work
But How convert the sql query to laravel eloquent?
I find it difficult to convert the sql query in laravel eloquent. Because the query is very complex
How can I solve this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire