title: Selecting a random value from unions
body: <p>I have the following query (I will omit the bindings to clarify things up):</p>
  
  <pre><code>(select * 
  from advertisements 
  where city_id is null and 
  category_id is null order by RAND() asc limit 1) 
  
   union 
  
  (select * 
  from advertisements 
  where city_id = ? and 
  category_id is null) 
  
  union 
  
  (select * 
  from advertisements where 
  category_id = ? and 
  city_id = ?) 
  
  union
  
  (select * 
  from advertisements 
  where city_id is null and 
  category_id = ?)
  </code></pre>
  
  <p>How do I select a random row from the selected rows? I.e. there are 3 unions. If the query returns 5 rows, how should I modify this query so that it returns a random row from those 5?</p>