我在mysql
中查詢group concats
記錄並給出具有冗餘標記的值。下面是查詢的輸出:mysql從字符串列表中獲得不同的標記
Problem Area->ACC-HO->ACC-HO->Credit Note (C/N)->Problem description ->Problem description
但我想這個字符串的鮮明標記,如下
Problem Area->ACC-HO->Credit Note (C/N)->Problem description
有沒有一種方法在sql SELECT
查詢本身做到這一點?
編輯 這裏是schema and query 下面是我的查詢:
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
你知道你並不需要所有那些醜陋的反引號? –
:-)是的,我知道... mysql客戶端.. – DarkKnightFan