Assume user table
| id | name | group |
| 1 | evan | admin |
| 2| charlie | admin|
| 3 | kid | user |
| 4 | ward | user |
|5 | fy | user |
select * from user group by user.group
Why there are only 2 pieces of data selected, instead of dividing users whose group is admin into one group, and grouping users whose group is admin The users of user are divided into a group
How can mysql achieve the desired effect...
Currently the only thing I can think of is to take them all out, then traverse user.group as the key, and then re-obtain the group. Can the database directly achieve this?
How to group with mysql? Repeated
mysql does not have it, just write one yourself, directly order by group to get the data, and then:
pseudo code
Collection operations in many languages already include such functions, such as java8...
This means dividing admin into one group and user into one group to get two pieces of data. I didn’t understand what the poster said