我在mysql
该group concats
记录中有一个查询,并给出了一个具有冗余标记的值。以下是查询的输出:
Problem Area->ACC-HO->ACC-HO->Credit Note (C/N)->Problem description ->Problem description
但我想要这个字符串的不同标记如下
Problem Area->ACC-HO->Credit Note (C/N)->Problem description
有没有办法在 sqlSELECT
查询本身中做到这一点?
编辑 这是架构和查询 以下是我的查询:
SELECT
t2.transaction_id AS transaction_id,
GROUP_CONCAT(
CONCAT(
t1.display_text,
'->',
(CASE (NOT EXISTS (SELECT 1 FROM mst_node a WHERE a.parent_node_id = t1.node_id))
WHEN 1 THEN t1.display_text ELSE
(SELECT b.display_text AS DISPLAY FROM mst_node b
WHERE parent_node_id = t2.node_id AND b.display_seq = t2.entered_value)
END)
)
ORDER BY t2.logtime_stamp SEPARATOR '->'
) AS display_text
FROM
mst_node t1
JOIN trn_user_log t2
ON t1.app_id = t2.app_id AND t1.node_id = t2.node_id
WHERE (t1.app_id = 105)
AND t1.parent_node_id IS NOT NULL
AND t1.save_as_default IS NULL
GROUP BY transaction_id,
mobile_no
ORDER BY t2.transaction_id DESC,
t2.logtime_stamp,
t2.mobile_no