title: Python: How to combine two SQL queries
body: <p>As I have limited knowledge about Python how can I crate in Python one query  which will contains both from below where second will be queried for when first will return not results (no email address returned)</p>
  
  <p>Code blow</p>
  
  <pre><code>bits = sys.argv[1].split('@')
  if len(bits) != 2:
      sys.exit(0)
  
  cur.execute("SELECT email FROM notifications WHERE diraddr = %s", (sys.argv[1],))    
  cur.execute("SELECT email FROM users WHERE (username LIKE %s) AND (domain LIKE %s) and notifications = 'Y'", (bits[0], bits[1]))
  </code></pre>
  
  <p>I have tried to do IF...ELSE for <code>email</code> return results from  first SQL query but it looks like can be done in one query without IF...ELSE statement.</p>