I try to select all the items from stores table that can belong to multiple categories
This is my table structure:
stores table
id
name
categories table
id
name
store_category table
store_id
category_id
I've tried the folowing query but it doesn't work as i wanted:
SELECT * FROM (stores JOIN store_category ON stores.id = store_category.store_id) JOIN categories ON store_category.category_id = categories.id
What i want to do is like:
Select all
storesthat have category_id = php var $category_id set instore_category
*added as pseudocode
How can i do this?
PS: example of populated tables
`stores`
id | name
1 | amazon
1 | aliexpress
`categories`
id | name
1 | smartphones
2 | fashion
`store_category`
store_id | category_id
1 | 1
1 | 2
2 | 1
2 | 2
From this table design i want to express that both stores are included in the two categories