title: Second SELECT query if first SELECT returns 0 rows
body: <p>I am trying to speed up a PHP script and I am currently pushing some PHP logic in the Mysql domain of the thing. Is there a way to make a different select query if the first Select returns no rows, or a count of zero ?</p>
  
  <p>Keeping in mind that the first query needs to run first, and the second should <strong>only</strong> be activated if the first one returns an empty set.</p>
  
  <pre><code>SELECT * FROM proxies WHERE (A='B') || SELECT * FROM proxies WHERE (A='C')
  </code></pre>
  
  <p>For the above 2 queries I have this code, but it seems to run each query twice (once to count, and once to return). Is there a better way to do this?</p>
  
  <pre><code>IF (SELECT count(*) FROM proxies WHERE A='B')&gt;0
      THEN SELECT * FROM proxies WHERE A='B'
  ELSEIF (SELECT count(*) FROM proxies WHERE A='C')&gt;0
      THEN SELECT * FROM proxies WHERE A='C'
  END IF
  </code></pre>