|-----------------------|-----------------------|
|article_title | article_author |
|-----------------------|-----------------------|
|部门变量测试01| zhang_gl |
|-----------------------|-----------------------|
|部门变量测试01| |
|-----------------------|-----------------------|
|部门变量测试01| xlzhang,Jacks |
|-----------------------|-----------------------|
DECLARE @str VARCHAR(8000)
SET @str = ''
SELECT @str = @str + ',' + article_author
FROM outcome_article
WHERE (article_title = '部门变量测试01') and len(article_author) > 0
SET @Article_Author = right(@Article_Author len(@Article_Author) -1)
查询结果:zhang_gl,xlzhang,Jacks
|article_title | article_author |
|-----------------------|-----------------------|
|部门变量测试01| zhang_gl |
|-----------------------|-----------------------|
|部门变量测试01| |
|-----------------------|-----------------------|
|部门变量测试01| xlzhang,Jacks |
|-----------------------|-----------------------|
DECLARE @str VARCHAR(8000)
SET @str = ''
SELECT @str = @str + ',' + article_author
FROM outcome_article
WHERE (article_title = '部门变量测试01') and len(article_author) > 0
SET @Article_Author = right(@Article_Author len(@Article_Author) -1)
查询结果:zhang_gl,xlzhang,Jacks