Jump to content

MYSQL - How to compare multiple columns for matching categories


andresfz87

Recommended Posts

I have a table named PRODUCTS with 3 columns for three different categories, i want to select all products which have any of the 3 values in any of the 3 columns. What i'm trying to do is show related products based on any of the 3 categories.

 

Example table:

 

id,name,cat1,cat2,cat3

 

1,Keyboard,2,8,4 2,Mouse,2,NULL,NULL 3,Monitor,16,2,NULL

 

Let's supose i'm viewing ITEM id=1, i want to do a query to show the other 2 products that have category number 2 in any of the 3 columns.

 

How do I do that?

 

Thank you very much,

Andres

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.