I have a String which is a comma spearated list of values.
I now need to take each value from this string (while there are still values in the string) and use them in a query one by one. Essentially, I want to loop once for each value in the string. How can I do this?
Here's what I want to achieve...
set @my_string = 'john, lisa, matt, beth, stu'
for every item in @my_string
select *
from details
where name = (item in @my_string)
get next value...
I am not sure of the syntax...
I would appreciate any help.
Thanks a lot.
I now need to take each value from this string (while there are still values in the string) and use them in a query one by one. Essentially, I want to loop once for each value in the string. How can I do this?
Here's what I want to achieve...
set @my_string = 'john, lisa, matt, beth, stu'
for every item in @my_string
select *
from details
where name = (item in @my_string)
get next value...
I am not sure of the syntax...
I would appreciate any help.
Thanks a lot.