Why does the order change after mysql uses group_concat?
天蓬老师
天蓬老师 2017-05-18 10:49:30
0
1
884

Since the fields in the two tables contain a one-to-many relationship, the group_concat function was used to splice multiple pieces of data when constructing the view to reduce the amount of data. However, after splicing, it was found that the original order had changed.
For example :
raw data:

    a                  1
    a                  2
    a                  3

Expected results:

    a                  1,2,3

actual results:

    a                  2,1,3 (或者其他 总之顺序改变了)
    

what happened?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
淡淡烟草味

It has to do with associated fields and extracted fields. Just sort internally group_concat(id order by id)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template