SELECT email_id from A;
给了我
A@g.com b@g.com c@g.com
我想要单行输出
A@g.com;b@g.com;c@g.com
答案 0 :(得分:0)
Select Stuff((Select ','+EmailColumnName from TableName for Xml Path('')),1,1,'');
或者如果你的电子邮件已经在On Row上而不是,,,
Select Replace(EmailColumnName,' ',';') from TableName
答案 1 :(得分:0)
DECLARE @myString as NVARCHAR(MAX) = N''
SELECT @myString = @myString + CASE WHEN @myString = '' THEN '' ELSE ';' END + email_id FROM A;
SELECT @myString;
答案 2 :(得分:0)
SELECT GROUP_CONCAT(email_id SEPARATOR ';') FROM A;
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat