I have three tables:
- products with an id (PK), name, etc ...
- brands with an id (PK), brand_label, etc ..
- brands_products with an id (PK), product_id, brand_id
SELECT products.* FROM products LEFT OUTER JOIN brands_products brands_products ON products.id = brands_products.product_id LEFT OUTER JOIN brands brands ON brands.id = brands_products.brand_id WHERE brands.brand_url = 'gucci'
and it returns only one result ...
As this is something I will do often, what is the right way to get the correct joins within Datamapper?