【发布时间】:2018-06-04 07:10:18
【问题描述】:
使用MySQL,我可以执行以下操作:
SELECT c.id_category, c.id_category_type, c.label, c.id_parent
FROM category c
WHERE c.id_category_type < 3
ORDER BY c.id_category_type;
结果是:
id_category |id_category_type |label |id_parent |
------------|-----------------|----------------------|----------|
1 |1 |Demande d'information |-1 |
2 |1 |Réclamation |-1 |
18 |1 |TEST |-1 |
3 |2 |Autre |1 |
4 |2 |Mairie |1 |
5 |2 |Stationnement |1 |
6 |2 |Autre |2 |
7 |2 |Familles |2 |
19 |2 |TESTDOMAINE |18 |
但我只想要concat 行,我有一个id_category 和id_parent
示例:
Autre-Demande d'information
Mairie-Demande d'information
Stationnement-Demande d'information
Autre-Réclamation
Familles-Réclamation
TESTDOMAINE-TEST
我在 MySQL Doc 上寻找了一个函数,但它看起来不像 CONCAT 或 CONCAT_WS 函数接受结果集,所以这里有人知道如何做吗?
【问题讨论】: