The magic of MySQL will support select * from the Employee group by name This counter-logical SQL (assuming that the table is not just a column of name)
The logic of MySQL is: The return field of select, if not in GroupBy, is not a statistical function, then the value of the field is randomly taken from the matching record, when the table correlation statistics, you can simplify the group by after the field, only need group by parent.id Instead of having all of the parent's fields listed
In the case of table correlation statistics, this feature of MySQL simplifies the field behind group by, but it doesn't have much to do with sorting.
For example, the order Form INV and the schedule item, if you want to return all the fields of inv and the number of item, you can write:
Select Inv.*, COUNT (itme.id) Item_count
From INV LEFT JOIN item on INV.ID=ITEM.INV_ID
GROUP BY Inv.id
What is the meaning of MySQL--select * from the Employee group by name syntax?