我有两个sql查询
第一:
SELECT ticketing_ticket.id, ticketing_ticket.email,
CONCAT(
TIMESTAMPDIFF(day,date_create,date_close) , ' jours ',
MOD( TIMESTAMPDIFF(hour,date_create,date_close), 24), ' heures ',
MOD( TIMESTAMPDIFF(minute,date_create,date_close), 60), ' miinutes '
) AS 'temps de traitement '
FROM ticketing_ticket WHERE DATE(date_close) = CURDATE();
输出:
| email | Time
|test@test.com | 15 jours 23 heures 7 miinutes
|test@test.com | 15 jours 22 heures 54 miinutes
第二:
SELECT GROUP_CONCAT(T2.label SEPARATOR ';') AS 'Domaines'
FROM (
SELECT
@r AS _id,
(SELECT @r := id_parent FROM ticketing_category WHERE id_category = _id) AS parent_id,
@l := @l + 1 AS lvl
FROM
(SELECT @r := 38, @l := 0) vars,
ticketing_category m
WHERE @r <> 0) T1
JOIN ticketing_category T2
ON T1._id = T2.id_category
ORDER BY T1.lvl DESC
输出:
| Domaines |
|Elections;Aides et démarches |
如何将sql查询组合成这样一个结果
| email | Time | Domaines
|test@test.com | 15 jours 23 heures 7 miinutes | Elections;Aides et démarches
|test@test.com | 15 jours 22 heures 54 miinutes | Elections;Aides et démarches
更新:
我在票务和票务类别之间的连接是id类别
2条答案
按热度按时间aiqt4smr1#
因为您似乎对如何连接记录没有任何要求,所以可以简单地进行交叉连接。
wgeznvg72#
试试看:
输出: