I have a product table, category table and another table to join product and category where category stored in JSON format. What I need to do is to get all the product with a list category IDs.
Category table
Code:
-----------------------
| id | category_name
-----------------------
Product table
Code:
-----------------------
| id | product_title
-----------------------
Product Category relation table
Code:
-----------------------
| product_id | categories [varchar(100) but data stored in JSON format]
-----------------------
| 1 | [1,4,6]
-----------------------
| 2 | [34,8,9]
-----------------------
| 2 | [27,18,29]
According to example, what will be the query if I need to get all the product with the category list (array)[34,18,6]
I will be very glad if you suggest any better table structures. Thanks in advance.
"Who thinks in code"
Perfectly describes who I am
mbparvez.me