Your select * is originally not a rigorous way of writing, but MySQL has strong compatibility and defaults to the smallest one. If SQL has group by, then the select can only contain columns in group by or aggregation functions , you commented that order by cannot be done because you need to add an alias to the column after max.
select max(id) id, catid from post group by catid order by id desc;
Your select * is originally not a rigorous way of writing, but MySQL has strong compatibility and defaults to the smallest one. If SQL has group by, then the select can only contain columns in group by or aggregation functions , you commented that order by cannot be done because you need to add an alias to the column after max.
gruop by catid written at the back