News for hackers. Stuff that matters.
Re:Let's Talk about Joins by jayknight on Monday January 22, 2024 @07:16PM (#39097523)
left join requires an `on` clause, which can feel out of place when doing it like this, but makes sense when you consider the parenthesized join to be a relation itself

  c left join (  
    a left join b on a.a_id = b.a_id  
  ) on c.a_id = a.a_id
The parenthesis syntax is also super useful when you want to left join to a group of tables that all need to inner join together:

  a left join (
    b inner join c 
     on b.b_id = c.b_id
    inner join d
      on c.c_id = d.c_id
    inner join e
      on d.e_id = e.e_id
  )
  on a.b_id = b.b_id
that way, the b/c/d relation is all or nothing instead of the possibility of get values from b but not c and d.

There are no comments on this comment yet.