title: Merge two complex MYSQL queries
body: <p>i want help on a way to merge two complex MYSQL queries.</p>
  
  <p>Query 1:</p>
  
  <pre><code>SELECT  p.*
  FROM    posts p
      INNER JOIN
      (
          SELECT  a.ID
          FROM    posts a
                  INNER JOIN post_tags b
                      ON a.ID = b.post_ID
          WHERE   a.post LIKE '%mmmm%' AND
                  b.tagname IN ('#test','#iseeyou')
          GROUP   BY ID
          HAVING  COUNT(DISTINCT b.tagname) = 2
      ) sub ON p.ID = sub.ID
  ORDER   BY p.upvotes DESC, p.unix_timestamp DESC
  </code></pre>
  
  <p>Query 2:</p>
  
  <pre><code>SELECT p.*, ((upvotes + 1.9208) / (upvotes + downvotes) - 1.96 * SQRT((upvotes * downvotes)
   / (upvotes + downvotes) + 0.9604) / (upvotes + downvotes))
   / (1 + 3.8416 / (upvotes + downvotes)) AS ci_lower_bound 
   FROM posts p WHERE upvotes + downvotes &gt; 0 
   AND p.unix_timestamp BETWEEN 1363023402 AND 1363109802 ORDER BY ci_lower_bound DESC
  </code></pre>
  
  <p>A small table definition is given at <a href="http://www.sqlfiddle.com/#!2/56c63/1" rel="nofollow">SQL Fiddle</a></p>
  
  <p>Actually, the first one is a search query and the second one gives the most popular results based on votes in the last 24 hours, so i want use the search query based on the formula used in the second one and also the time range</p>