jeudi 13 août 2015

How to delete all but most recent row where other columns are equal

I have a MySQL table, an excerpt of which is here:

http://ift.tt/1WnpK6F

I need to keep the most recent row for each row where the assoc_case, document, and participant are the same. For example, I only want to keep row 136 out of rows 133-136.

I'm working from this, but can't seem to adapt it for my needs:

SELECT id, assoc_case, participant, document, MAX(created) FROM `table` GROUP BY created, assoc_case, participant, document



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire