group_concat usage of sql

Description group_concat (), in the manual: This function returns the string with a non-NULL value results from the connection of one group . More abstract and difficult to understand.

Popular point to understand, in fact, is this: group_concat () will calculate which rows belong to the same group, belonging to the same group of columns displayed. To return to the column which is determined by function parameters (that is, the field name). Packet must have a standard, is grouped according to the group by the specified column.

test:

SELECT scene_code,GROUP_CONCAT(status) FROM fus_recom_config WHERE status in ('DRAFT','PRE','GRAY','PROD') GROUP BY scene_code;

result:

 

Guess you like

Origin www.cnblogs.com/panbingqi/p/10944770.html