I'm storing car parts in a database. Obviously, some parts will only fit on certain years of a certain vehicle.
When inputting the parts to MySQL, I'm having the user just use this format for the dates, "41, 42, 43, 45, 46" etc.. I then just implode, explode in PHP. That works, for what I needed to do.
Now I need to pull parts based on the years they are available. I don't want to have to use a multiple select box in my form if I can help it.
Never, ever store more than one information in a single field, if you want to access them separately. Never.
You will need to rework you DB to have a jointable between model years and parts instead of haveing all model years crammed into a single field of your parts table.
Some tricky textual select will sort of work, but it will definitly kill your performance. If this is about a full parts catalog even for a single model, it will kill your performance to the point of unusability.
Sorry: Better honest than polite, if you really can't have both.
You have a many-to-many relationship...So create another table
part_id | Year -------------- 1 1995 1 1996 2 1995 2 1997 3 1998
Then you can get all the years a part works with using something like
select * from parts join parts_years on (part_id = parts.id);