-2
MySQL的:如何在MySQL中使用group_concat()?
SELECT
group_concat(cu1.cu_inflow_type),count(cu1.cu_inflow_type)
FROM cs_test cu1
LEFT JOIN cs_test cu2
ON cu2.seq=cu1.seq
GROUP BY cu1.cu_inflow_type
結果:
======================================================================
group_concat(cu1.cu_inflow_type) | count(cu1.cu_inflow_type)
----------------------------------------------------------------------
001,001,001,001,001,001,001,00.. | 27
002,002 | 2
003,003 | 2
004,004,004 | 3
005 | 1
006 | 1
----------------------------------------------------------------------
查詢運行,但它不是我想要的結果。我想它看起來像:
======================================================================
group_concat(cu1.cu_inflow_type) | count(cu1.cu_inflow_type)
----------------------------------------------------------------------
001,001,001,001,001,001,001,00.. | 27
002,002,003,003 | 4 <-- add!
004,004,004 | 3
005,006 | 2 <-- add!
----------------------------------------------------------------------
「002002」 +「003003」 = 002002003003 我不知道如何使用group_concat()
在MySQL中得到期望的結果。有人能幫我嗎?
我對你想要的實際輸出有點困惑。你能解釋一下嗎? – Takarii
如果你需要WHERE子句 – Oncodeeater