title: SQL Multiple Joins - How do they work exactly?
body: <p>I'm pretty sure this works universally across various SQL implementations. Suppose I have many-to-many relationship between 2 tables: </p>
  
  <pre><code>Customer: id, name
  </code></pre>
  
  <p>has many:</p>
  
  <pre><code>Order: id, description, total_price
  </code></pre>
  
  <p>and this relationship is in a junction table:</p>
  
  <pre><code>Customer_Order: order_date, customer_id, order_id
  </code></pre>
  
  <p>Now I want to write SQL query to join all of these together, mentioning the customer's name, the order's description and total price and the order date:</p>
  
  <pre><code>SELECT name, description, total_price FROM Customer
  JOIN Customer_Order ON Customer_Order.customer_id = Customer.id
  JOIN Order = Order.id = Customer_Order.order_id
  </code></pre>
  
  <p>This is all well and good. This query will also work if we change the order so it's <code>FROM Customer_Order JOIN Customer</code> or put the <code>Order</code> table first. Why is this the case? Somewhere I've read that <code>JOIN</code> works like an arithmetic operator (+, * etc.) taking 2 operands and you can chain operator together so you can have: 2+3+5, for example. Following this logic, first we have to calculate 2+3 and then take that result and add 5 to it. Is it the same with JOINs?</p>
  
  <p>Is it that behind the hood, the first JOIN must first be completed in order for the second JOIN to take place? So basically, the first JOIN will create a table out of the 2 operands left and right of it. Then, the second JOIN will take that resulting table as its left operand and perform the usual joining. Basically, I want to understand how multiple JOINs work behind the hood.</p>