mysql> select * from t_subject;
| id | uid | subject |
| 1 | 1 | aa |
| 2 | 2 | bb |
| 3 | 3 | cc |
| 4 | 4 | dd |
| 5 | 2 | ee |
| 6 | 2 | rr |
| 7 | 3 | tt |
| 8 | 2 | yy |
| 9 | 3 | qq |
| 10 | 4 | oo |
| 11 | 3 | pp |
| 12 | 3 | kk |
| 13 | 1 | mm |
| 14 | 4 | nn |
| 15 | 1 | ss |
| 16 | 4 | vv |
| 17 | 1 | ff |
mysql> select uid,group_concat(a.subject) from t_subject a group by a.uid ;
| uid | group_concat(a.subject) |
| 1 | aa,ff,ss,mm |
| 2 | yy,rr,ee,bb |
| 3 | kk,pp,xx,qq,tt,cc |
| 4 | nn,dd,vv,oo |
----我想要的是如下效果的 该怎么写啊(就是取出分组后每组的前三条记录)---
| uid | group_concat(a.subject) |
| 1 | aa,ff,mm |
| 2 | yy,rr,ee |
| 3 | kk,pp,xx |
| 4 | nn,dd,vv |
要排序的啊!用substring不过必须要排序后才能截取啊