title: mysql select with time range and condition
body: <pre><code>error_tbl                   success_tbl
  id | creationTime           id|creationTime
  1    2014-09-23 10:03:40    1212 2014-09-23 10:02:40
                              1213 2014-09-23 10:03:40
                              1214 2014-09-23 10:10:40
  </code></pre>
  
  <p>After run of query I want to have this:</p>
  
  <pre><code>result table
  creationTime        | fail_ids | succ_ids
  2014-09-23 10:03:40, 1,          NULL
  2014-09-23 10:02:40, NULL,       1212 
  2014-09-23 10:03:40, NULL,       1213 
  </code></pre>
  
  <p>I want to select all data (success and fail) within time range of EACH AND EVERY 5 minutes only if any record exists in error_tbl within that period.</p>
  
  <pre><code>(SELECT
      creationTime, 
      id as  fail_ids,null as succ_ids
  FROM error_tbl a
  
   UNION
  SELECT
      creationTime,  
      null as fail_ids ,id as succ_ids
  FROM success_tbl b
   ) s
  </code></pre>