title: Combining two SELECT query that Do not Intersect
body: <p>Suppose we have three tables. Table 2 and 3 intersect with the table 1 but not with each other.
  <img src="https://i.stack.imgur.com/VWlgW.jpg" alt="enter image description here"></p>
  
  <p>Two separate INNER JOIN queries get the common column values between table 1 &amp; 2 and table 1 &amp; 3.</p>
  
  <p>Now my question is how to put these two intersections together; simply INNER JOINing these table will not yield any result:</p>
  
  <p>The following would be an ideal result.
  <img src="https://i.stack.imgur.com/QhNZN.jpg" alt="enter image description here"></p>
  
  <p>This is as close I have gotten to the desired result, but not close enough.
  <div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>SELECT * FROM 
   (SELECT `tag_map`.`id`,`resource`.`resource_type_id`,`resource`.`title` FROM `tag_map`
          INNER JOIN `resource`
          ON `tag_map`.`tag_id` = '8'
              AND `tag_map`.`entity_type_id`= '1'
              AND `resource`.`id` = `tag_map`.`entity_id`) AS t1
  INNER JOIN 
   (SELECT `name`,`location` FROM `tag_map`        
          INNER JOIN `userinfo`
          ON `tag_map`.`tag_id` = '8'
              AND `tag_map`.`entity_type_id`= '2'
              AND `userinfo`.`id` = `tag_map`.`entity_id`) AS t2</code></pre>
  </div>
  </div>
  </p>
  
  <p>The problem with this query is that the JOIN clause mixes the rows and I get this</p>
  
  <p><img src="https://i.stack.imgur.com/tYxWe.jpg" alt="enter image description here"></p>