The user
Id name
1 a
2 b
MSG
Id uid content
1
1 qq2 1 ss
3 2 dd
Now I just want to query the user information and their speech, and can be sorted by the number of statistics, which is below the result set;
how to write a statement?Id name count
1 a 2
2 b 1
CodePudding user response:
The SELECT m.u id as id, u.n ame, count (m.u id) from ` user ` u, MSG m WHERE u.i d=m.u id group by uidCodePudding user response:
The select t.i d id, t.n ame name, count (m.c ontent) CNTFrom the user t, MSG m
Where t.i d=m.u id
Group by t.i d
The order by CNT.