programing

MySQL: GROUP_CONCAT 값 정렬

kingscode 2022. 9. 27. 21:42
반응형

MySQL: GROUP_CONCAT 값 정렬

요컨대 GROUP_CONCAT 문에서 값을 정렬할 수 있는 방법이 있습니까?

쿼리:

GROUP_CONCAT((SELECT GROUP_CONCAT(parent.name SEPARATOR " » ") 
FROM test_competence AS node, test_competence AS parent 
WHERE node.lft BETWEEN parent.lft AND parent.rgt 
  AND node.id = l.competence 
  AND parent.id != 1 
ORDER BY parent.lft) SEPARATOR "<br />\n") AS competences

다음 행이 표시됩니다.

공예 join 조이너리

관리 »조직

나는 이렇게 하고 싶다:

관리 »조직

공예 join 조이너리

네, http://dev.mysql.com/doc/refman/...tions.http #function_group-concat을 참조하십시오.

SELECT student_name,
  GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ')
  FROM student
  GROUP BY student_name;

주문하실 건가요?

SELECT _key,            
COUNT(*) as cnt,            
GROUP_CONCAT(_value ORDER BY _value SEPARATOR ', ') as value_list      
FROM group_concat_test      
GROUP BY _key      
ORDER BY _key;

언급URL : https://stackoverflow.com/questions/995373/mysql-sort-group-concat-values

반응형