title: SQL SELECT Columns From Multiple Tables Without Repeating Data
body: <p>I am trying to query 2 tables using the following sql statement in an attempt to return all records from each table that contains a specific id.</p>
  
  <pre><code>SELECT Phone.Phone, Email.Email FROM Contacts.Phone, Contacts.Email 
  WHERE Phone.ContactId = :contactId AND Email.ContactId = :contactId
  </code></pre>
  
  <p><code>Contacts.Phone</code> table contains 2 phone numbers for the given id and <code>Contacts.Email</code> contains 1 email for the given id. Using the above sql query, I get the following rows returned. This is just an example, of course, of a situation in where my result set from each table does match in number of rows.</p>
  
  <pre><code>Row 1: 555-555-5555 - email@email.com
  Row 2: 666-666-6666 - email@email.com
  </code></pre>
  
  <p>The email is repeated in order to fill in the second row when I am trying to get:</p>
  
  <pre><code>Row 1: 555-555-5555 - email@email.com
  Row 2: 666-666-6666 - NULL
  </code></pre>
  
  <p>I think I need to use a <code>UNION</code> to somehow join the tables, but I can't figure out exactly how to write the sql statement. Another option would be to perform 2 separate SQL queries, which would be easier but I figure performance wise it would be better to collect all data I need in one query.</p>
  
  <p>I am using MySQL.</p>