title: How to double JOIN properly in SQL
body: <p>I'm trying to select all <code>transactions</code> with the billing_address city in 'New York', but with the shipping_address city not in 'New York'. The problem I'm struggling with is that when looking at the <code>transactions</code> table, there's two columns (<code>shipping_address_id</code> and <code>billing_address_id</code>), where the respective id for both is stored in the<code>address_table</code> as two seperate records.</p>
  
  <p>Since I need to check whether or not the shipping/billing address is 'New York' for both those columns in the <code>transactions</code> table, I'm trying to do a double join to the <code>address_table</code> in my query, though it doesn't seem to be working properly. Does anyone see where I'm going wrong here? Thanks!</p>
  
  <pre><code>SELECT billing.id AS billing_address, shipping.id AS shipping_address
  FROM transactions AS t
  LEFT JOIN address_table AS billing
  ON t.billing_address_id = billing.id
  AND billing.city = 'New York'
  AND t.billing_address_id IS NOT NULL
  LEFT JOIN address_table AS shipping
  ON t.shipping_address_id = shipping.id
  AND shipping.city != 'New York'
  AND t.shipping_address_id IS NOT NULL;
  </code></pre>