3 回答

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊
而不是使用group concat()你可以使用concat()
Select concat(Col1, ',', Col2) as Foo_Bar from Table1;
編輯它只適用于mySQL; Oracle concat只接受兩個(gè)參數(shù)。在oracle中,您可以使用select col1 ||','|| col2 ||','|| col3之類的東西作為來自table1的foobar; 在SQL Server中你會(huì)使用+而不是管道。

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超4個(gè)贊
在我的情況下,我必須連接一個(gè)人的手機(jī)號(hào)碼唯一的帳號(hào)。所以我使用以下查詢來實(shí)現(xiàn)這一點(diǎn)。
SELECT GROUP_CONCAT(AccountsNo) as Accounts FROM `tblaccounts` GROUP BY MobileNumber
查詢結(jié)果如下:
Accounts
93348001,97530801,93348001,97530801
89663501
62630701
6227895144840002
60070021
60070020
60070019
60070018
60070017
60070016
60070015
添加回答
舉報(bào)