cyberfly
1/3/2019 - 4:21 AM

Mysql group by get latest row

Normal group by will show the first result. To get the last result for group by, use max()

https://paulund.co.uk/get-last-record-in-each-mysql-group

select max(id) from company_relocation_histories group by company_id