title: Combine two SELECT queries IF one is not found
body: <p>I'm looking to combine two select queries into one query efficiently with performance in mind.</p>
  
  <p>I want the first <code>SELECT</code> to get a row. If the row does <strong>not</strong> exist, then run the other <code>SELECT</code> query. If the row does exist from the first query, then use the row found in the first query and do not run/get anything from the second query.</p>
  
  <p>Here are my two queries:</p>
  
  <pre><code>$stmt = $dbh-&gt;prepare("SELECT * FROM users WHERE unique_code = :unique_code LIMIT 1");
  $stmt-&gt;bindParam(':unique_code', $uniqueCode);
  $stmt-&gt;execute();
  $row = $stmt-&gt;fetch();
  
  if(!$row) { // If row does not exist
      $stmt = $dbh-&gt;prepare("SELECT * FROM users WHERE birthday = :birthday LIMIT 1");
      $stmt-&gt;bindParam(':birthday', $birthday);
      $stmt-&gt;execute();
      $row = $stmt-&gt;fetch();
  }
  </code></pre>
  
  <p>How can I do that?</p>
  
  <p>EDIT: sample data:</p>
  
  <pre><code>id | unique_code | birthday
  -----------------------------
   1       123      1987-05-20
   2       456      1955-03-10
  </code></pre>