title: Using SQL concat and coalesce to display when values are null
body: <p>I have the following table.  city, state, and zipcode are all varchar type and can be NULL.</p>
  
  <pre><code>MyContacts
  -id (int PK)
  -city (varchar null)
  -state (varchar null)
  -zipcode (varchar null)
  </code></pre>
  
  <p>I would like to return city, state, and zipcode formatted as a single value as follows:</p>
  
  <pre><code>Seattle WA 98423 if all are not NULL
  Seattle WA if zip is NULL
  Seattle 98423 if state is NULL
  WA 98423 if city is NULL
  Seattle if state and zip is NULL
  WA if city and zip is NULL
  98423 if city and state is NULL
  NULL if all of them are NULL
  </code></pre>
  
  <p>I have been trying something like the following, but think I am going about it wrong.  Thanks</p>
  
  <pre><code>SELECT COALESCE(CONCAT(city," ",state," ",zipcode),CONCAT(city," ",states),zipcode) AS location
  </code></pre>