title: Cross Referencing Multiple Tables
body: <p>What I was trying to do is to get data from multiple tables, supposed that I have the following results in my query: 
  <a href="https://i.stack.imgur.com/WVJq6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WVJq6.png" alt="enter image description here"></a></p>
  
  <p>The numbers in the column ticket_item_type represents certain table. For example, 2 is for tbl_company and 3 is for tbl_lease. Then the details represents the id of a certain record in that table.</p>
  
  <p>Suppose that I want to get the title of those records using ticket_item_type and details. Is it possible to embed it to the results? Or should I make separate queries for each.</p>
  
  <p>I know JOIN, but I is it only for single table?</p>
  
  <p>Here's my MYSQL query for the image above:</p>
  
  <pre><code>SELECT *
  FROM
    (SELECT *
     FROM ticket_items
     WHERE hs_customer = 1
       AND ticket IN
         (SELECT id
          FROM tickets
          WHERE hs_customer='1'
            AND ticket_status = 'dispatch_reviewed')
       AND ticket IN
         (SELECT ticket
          FROM ticket_items
          WHERE ticket_item_type = 5
            AND details = '159')) AS TB1
  WHERE ticket_item_type IN (3,
                             2,
                             8)
  </code></pre>