I need help with sql select from multiply tables.
Tables:
s_products
- id
- name
- url
- brand_id
s_products_categories
- product_id
- category_id
s_brands
- id
- name
- url
s_categories
- id
- name
- url
Compare:
s_products.id = s_products_categories.product_id
s_categories.id = s_products_categories.category_id
s_products.brand_id = s_brands.id
And result needed:
1) $products['s_categories.url']['s_brands.url']['s_products.url'] = 's_products.name';
2) $brands['s_categories.url']['s_brands.url'] = 's_brands.name';
Can you help me to do it in one select (or more)?
Try:
To see combinations of specific fields (eg. category_url with brand_url), add
distinctimmediately afterselectand remove the fields that aren’t required.