larrycarl Posted June 29, 2010 Share Posted June 29, 2010 Hi, I have some product that fall under multiple categories, so category number "2,3" for example would be stored under category column in table 'product'. But when I try to match the category number with table 'categories' it doesn't work, only products with number without comma return result. Here's the code: sql = mysql_query("SELECT * FROM product WHERE category = '$cid' ORDER BY dateadded DESC"); How do I make it to recognize each number as individual after comma so it would return result for both category 2 & 3? Thank you! Best, Larry Link to comment https://forums.phpfreaks.com/topic/206200-how-to-match-comma-separated-values-in-mysql-database/ Share on other sites More sharing options...
Mchl Posted June 29, 2010 Share Posted June 29, 2010 You didn't normalise your database design, so now it kicks your rear end. You should have a many-to-many realtion between products and categories. Link to comment https://forums.phpfreaks.com/topic/206200-how-to-match-comma-separated-values-in-mysql-database/#findComment-1078795 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.