select @mailto=@mailto+';' + distinct(email) from a
’distinct‘该放在哪里?
------解决思路----------------------
select distinct xxxxxxxxx
------解决思路----------------------
建议用GROUP BY 代替
select @mailto=@mailto+';' + (email) FROM(SELECT email FROM a GROUP BY email)b