Problem in a nutshell involves: breaking contents of field by comma and searching against search form input.
I am looking to set up a table with the following logic...
Item ID auto-incremented #
Categories selection of numbers sep. by commas (2,5,12,3)
Name desc. text
Colors selection of numbers sep. by commas (2,4,6)
ItemID | Categories | Name | Colors
1 | 2,3 | This | 1,2,3
2 | 1,2 | That | 3,1
My Categories and colors are determined in sep tables like
ColorID auto-incremented #
Color_Name Name to display
ColorID | Color_Name
1 | White
2 | Black
3 | Blue
CatID auto-incremented #
Cat_Name Name to display
CatID | Cat_Name
1 | Widgets
2 | Fidgets
3 | Nods
The idea being that an ITEM can belong to multiple Categories and be available in multiple colors without having to have a separate table entry for each variation.
how can i string together a select for this? let's say I want a list of all ITEMS that contain a ColorID of 2 and/or 1 and CatID of 3?
I mean typically I could "SELECT * WHERE Categories = 3" for the Category portion, but the actual Categories value stored is "2,3" or "1,3,5" -- not the number 3. I don't think LIKE will work either because it would match 3 and 13 and 23 etc if the field contained "1,13,6,3"
I know that I can send a string of comma separated values to compare against a single value in my table (ie: (Colors IN 1,4,2)) but that seems to presume that the value of Colors would be a single value -- when it will actually be a series of comma separated values.
I want to avoid a reiterating loop of search results process through further searches, etc to weed out my results while keeping the search function quick and low on resources --- any ideas on what kind of SELECT structure I would need to use?
ANY HELP is greatly appreciated.
Thanks!