-
You do JOINs in this query, but it is implicit because you select from multiple tables.
-
What happens here is called subquery (query within a query). It's pretty useful and sometimes can make things less complex. You can read more about it here: https://dev.mysql.com/doc/refman/8.0/en/subqueries.html
Dec 12, 2019
2
Level 27
SQL Join
Ever seen this type of query for join:
1
select c.variant,c.unit,c.price,c.sku, a.freshness, b.*, d.parent_id, d.id, d.slug From product_catalogs a, product_catalog_translations b,
product_price_lists c,
product_categories d
where a.id=b.product_catalog_id
and b.locale='en'
and a.id=c.product_catalog_id
and a.deleted_at is null
and a.is_archive=0
and d.id = a.product_category_id;
What would you call this type of sql query? I normally use inner join, left join or right join to join table. Yet, this method does not work when you want to query database to export join data in excel.
ref: http://www.sql-join.com/sql-join-types
2
select a.product_category_id,a.name,b.parent_id,c.name from product_category_translations a,
product_categories b,
(select product_category_id,name from product_category_translations a,
product_categories b
where a.locale='en'
and a.product_category_id=b.id
and b.parent_id is null) c
where a.locale='en'
and a.product_category_id=b.id
and b.parent_id=c.product_category_id
;
Ever seen this kind of query ? It has bracket in side of the query which I do not understand what is it for and what it means?
Please or to participate in this conversation.