title: How to make One Search Module for Multiple Tables in Codeigniter?
body: <p>I have to search for Either 'Professional' or 'Vendor' tables along with 'Users' table.. can you help me out of the query how i have make it possible in one search, to decide where the search belongs.</p>
  
  <p>The below result is looking for matches in tables.. i dont want that.. i want the right match in both individual tables.. can anyone help me ?</p>
  
  <pre><code>&lt;?php
  
  $this-&gt;db-&gt;select('*');
  $this-&gt;db-&gt;from('users');
  $this-&gt;db-&gt;join('professional', 'professional.accountId = users.id');
  $this-&gt;db-&gt;join('vendor', 'vendor.accountId = users.id');
  $this-&gt;db-&gt;like('users.realname', $search_term);
  $this-&gt;db-&gt;or_like('users.email', $search_term);
  $this-&gt;db-&gt;or_like('users.category', $search_term);
  $this-&gt;db-&gt;or_like('users.full_name', $search_term);
  $this-&gt;db-&gt;or_like('users.license_id', $search_term);
  $this-&gt;db-&gt;or_like('professional.state', $search_term);
  $this-&gt;db-&gt;or_like('professional.city', $search_term);
  $this-&gt;db-&gt;or_like('professional.country', $search_term);
  $this-&gt;db-&gt;or_like('professional.pincode', $search_term);
  $this-&gt;db-&gt;or_like('professional.mobile', $search_term);
  $this-&gt;db-&gt;or_like('professional.phone', $search_term);
  $this-&gt;db-&gt;or_like('professional.profession', $search_term);
  $this-&gt;db-&gt;or_like('vendor.state', $search_term);
  $this-&gt;db-&gt;or_like('vendor.city', $search_term);
  $this-&gt;db-&gt;or_like('vendor.country', $search_term);
  $this-&gt;db-&gt;or_like('vendor.pincode', $search_term);
  $this-&gt;db-&gt;or_like('vendor.mobile', $search_term);
  $this-&gt;db-&gt;or_like('vendor.phone', $search_term);
  $this-&gt;db-&gt;or_like('vendor.firm_catagory', $search_term);
  $this-&gt;db-&gt;group_by("users.id");
  
  $query = $this-&gt;db-&gt;get();
  
  $qu = $query-&gt;result_array();
  
  foreach ($qu as $row) {
  
  $row_set[] = htmlentities(stripslashes($row['accountId'])); //build an array
  }
  
  echo json_encode($row_set);
  </code></pre>
  
  <p>?></p>