retrieve comma delimited data from a field in using SQL

Posted by Nichols on Stack Overflow See other posts from Stack Overflow or by Nichols
Published on 2010-03-12T19:54:02Z Indexed on 2010/03/12 19:57 UTC
Read the original article Hit count: 273

Filed under:
|
|

I've created a form in php that collects basic information. I have a list box that allows multiple items selected (ie housing, rent, food, water). If multiple items are selected they are stored in a field called Needs seperated by a comma.

I have created a report ordered by the persons needs. The people who only have one need are sorted correctly, but the people who have multiple are sorted exactly as the string passed to the database (ie. housing, rent, food, water) --> which is not what i want.

Is there a way to seperate the multiple values in this field using SQL to count each need instance/occurance as 1 so that there are no comma delimitations shown in the results?

CLICK FOR EXAMPLE

© Stack Overflow or respective owner

Related posts about comma

Related posts about delimited