title: How to make where query with join
body: <p>I have a table in which i have four columns</p>
  
  <ol>
  <li>id</li>
  <li>user_type</li>
  <li>user_role</li>
  <li>org_id</li>
  </ol>
  
  <p>Now if the <code>user_type</code> is 1 (i.e individual) then the <code>user_role</code> and <code>org_id</code> will be null,
  but if the <code>user_type</code> is 2 (i.e organisation) then it will have <code>org_id</code> (id of the organisation) and <code>user_role</code> (his role in the organisation).</p>
  
  <p>There are three type of role in an organisation</p>
  
  <ol>
  <li>admin (only one person could be the admin).</li>
  <li>finance secrearty (could be more than one).</li>
  <li>approvers (also could be more than one).</li>
  </ol>
  
  <p>What I want
  I want to fetch only one person (probably admin of the organisation) if the <code>user_type</code> is 2 from each organisation and all the users having <code>user_type</code> 1.</p>
  
  <p>My table</p>
  
  <pre><code>-------------------------------------
  | tbl_user                           |  
  -------------------------------------
  | id | user_Type | user_role | org_id|
  --------------------------------------
  | 1  | 1         | null      | null  |
  | 2  | 2         | 1         | 1     |
  | 3  | 2         | 2         | 1     |
  | 4  | 2         | 3         | 1     |
  | 5  | 2         | 3         | 1     |
  | 6  | 1         | null      | null  |
  | 7  | 2         | 1         | 2     |
  | 8  | 2         | 2         | 2     |
  | 9  | 2         | 3         | 2     |
  | 10 | 2         | 3         | 2     |
  </code></pre>
  
  <p>by using query</p>
  
  <pre><code>SELECT * FROM YourTable t
  WHERE t.user_type = 1 
     OR t.user_role = 1
  </code></pre>
  
  <p>Expected result </p>
  
  <pre><code>-------------------------------------
  | tbl_user                           |  
  -------------------------------------
  | id | user_Type | user_role | org_id|
  --------------------------------------
  | 1  | 1         | null      | null  |
  | 2  | 2         | 1         | 1     |
  | 7  | 2         | 1         | 2     |
  | 6  | 1         | null      | null  |
  </code></pre>
  
  <p>Then i have to join the result with tbl_user_meta with (where zipcode = 85225).             </p>
  
  <p>My tbl_user_meta follows-</p>
  
  <pre><code> -------------------------------------
  | tbl_user_meta                       | 
  --------------------------------------
  | id | uid       | user_name | zipcode|
  --------------------------------------
  | 1  | 1         | abc       | 85225  |
  | 2  | 2         | asd       | 85225  |
  | 3  | 3         | asd       | 85225  |
  | 4  | 4         | sdf       | 345678 |
  | 5  | 5         | fgd       | 23456  |
  | 6  | 6         | rgy       | 23567  |
  | 7  | 7         | hyt       | 12345  |
  | 8  | 8         | ukl       | 12345  |
  | 9  | 9         | tko       | 21334  |
  | 10 | 10        | ert       | 85225  |
  </code></pre>
  
  <p>What i finally want to achieve is this record</p>
  
  <pre><code>-------------------------------------
  | tbl_user_meta                       | 
  --------------------------------------
  | id | uid       | user_name | zipcode|
  --------------------------------------
  | 1  | 1         | abc       | 85225  |
  </code></pre>
  
  <p>P.S - I am doing this with codeigniter</p>
  
  <p>Thanks.</p>