Skip to main content
September 9, 2008
Question

List not returning correct.

  • September 9, 2008
  • 1 reply
  • 313 views
I have a query that is trying to look through a list of numbers for a number passed to the function. I always get a result set of 0 unless there's only one item in the database list. In my database a "material_categories" looks like this "1,9,12,11,15,14"

my code is:
    This topic has been closed for replies.

    1 reply

    Inspiring
    September 9, 2008
    Your problem is caused by storing a comma delimited list in a database row. I recommend that you normalize your database design to eliminate storing the comma delimited values.

    You might also try the attached query to search your comma delimited strings for possible matches. This is not a pretty query and will perform poorly on a table with more than a few records in it.
    September 9, 2008
    So for each material that is in more than one category it would have a different record? So materials belonging to 5 categories would have 5 different records in the materials database. How is that faster or more efficient? What do you do when you have a product or item that belongs to more than class or categores?