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

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

file - Python: AttributeError: 'str' object has no attribute 'readlines' -

c# - Get the Class name in a class with atribute inside a attribute method -