Jump to content

How to match comma separated values in mysql database?


larrycarl

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.