title: MySQL IF NOT NULL, then display 1, else display 0
body: <p>I'm working with a little display complication here.  I'm sure there's an IF/ELSE capability I'm just overlooking.</p>
  
  <p>I have 2 tables I'm querying (customers, addresses).  The first has the main record, but the second may or may not have a record to LEFT JOIN to.</p>
  
  <p>I want to display a zero if there is no record in the addresses table. 
  And I want to only display 1, if a record exists.</p>
  
  <p>What I've attempted so far:</p>
  
  <pre><code>SELECT c.name, COALESCE(a.addressid,0) AS addressexists
  FROM customers c
  LEFT JOIN addresses a ON c.customerid = a.customerid
  WHERE customerid = 123
  </code></pre>
  
  <p>This first example does not do it.  But I may be utilizing COALESCE wrong.</p>
  
  <p>How can I display a 0, if null, and a 1, if something exists?</p>