SQL:SELECT * FROM list WHERE author IN(
SELECT STUFF((SELECT DISTINCT ','+
CAST(author as VARCHAR) FROM dbo.new_list WHERE id =100026 for xml path('')),1,1,''))
SELECT STUFF((SELECT DISTINCT ','+
CAST(author as VARCHAR) FROM dbo.new_list WHERE id =100026 for xml path('')),1,1,'')
这个查询结果为 name01,name02,name03,name04,name05
怎么变成 'name01','name02','name03','name04','name05'
给每个值加上单引号
不知所云
动态sql。declare @sql='select * ...';然后exec(@sql)