Reputation: 1
I have this table:
Group workers
I need all where worker_id = 3 (for example) and only max recent date_created.
Upvotes: 0
Views: 415
Reputation: 1986
Try using an SQL statement that selects the fields you want and include MAX(date_created)
. Then in the where clause put:
WHERE worker_id = 3 GROUP BY worker_id
This will give you only the most recently created record for each worker_id, and then you can filter out whichever one(s) you want with the where clause. I'm not familiar enough with CakePHP's database access layer to give the answer in that format but if you can get a working SQL statement, you can either use that or get some further help in converting for CakePHP.
Upvotes: 1