I have the following tables
Product
id int(11) AUTO_INCREMENT
name varchar(254)
slug varchar(254)
product_category_id int(11)
A Product belongs to a category in ProductCategories. A category has sub category(self join)
id int(11) AUTO_INCREMENT
name varchar(254)
slug varchar(254)
parent_id int(11)
A Product also has a icon stored in ProductMedia.
id int(11) AUTO_INCREMENT
url varchar(254)
type enum('icon','banner','video')
What is the most efficient way to get all products with it’s associated icon that belong to a category including products in it’s sub category. All relations here are has_one.