WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

SQL table or query issue

illumi

New member

0

0%

Status

Offline

Posts

48

Likes

0

Rep

0

Bits

250

5

Months of Service

0%
Hello friends, I am experiencing a logical issue in establishing a relationship between two tables in MySQL. I need to relate Products and Categories in a way that allows a product to be associated with multiple categories. However, I must establish the relationship in such a way that I can run a query like this: to show products that belong to categories with IDs 5 or 6, category ID 4, and category IDs 83 or 84. I have written the query like this for better clarification: SELECT * FROM XXX WHERE (cat_id=5 OR cat_id=6) AND (cat_id=4) AND (cat_id=83 OR cat_id=84). I have structured the query this way to express the desired outcome more clearly. While all categories will not be in a single ID format in the cat_id column, this is the result I am looking for. Is it possible? How should the table structure be designed?
 

249

6,622

6,642

Top