SQL Server Select With Loop on second table -
i struggling sql logic , wondered if can help?
i need list of id's table "roles" emailenabled true, need use these ids against table "users" on roleid column grab email addresses , return these comma separated list.
i know need use loop in here it's not strong point.
let me know if need further info.
i not recommend generating comma seperated list in sql. grab data need record-wise , handle rest in program logic.
you can data need this
select users.email users join roles on roles.id = users.roleid roles.emailenabled = 1
Comments
Post a Comment