title: How to make Codeigniter Split Search
body: <p>I want codeigniter search to be match with any one word to column.</p>
  
  <p>Example: Let's Say Search Query is "Fashion Outlet for Mens", Now in table column title is "Fashion Outlet" only so i want search input to be split word by word and match column.</p>
  
  <p>Any Help Please</p>
  
  <pre><code>public function search($query) 
    {
      $q = $this-&gt;db-&gt;from('tablename')
      -&gt;like('title',$query)
      -&gt;get();
      return $q-&gt;result();
    }
  </code></pre>
  
  <p>Updated Question</p>
  
  <pre><code>public function search_query($query,$limit,$offset) 
  {
      $keywords = explode(' ', $query);
  
      foreach ($keywords as $keyword)
      {
      $keyword = trim($keyword);
      $this-&gt;db-&gt;or_where("`title` LIKE '%$keyword%'");
      $this-&gt;db-&gt;join('table2', 'tablename.id = table2.id');
      $this-&gt;db-&gt;limit( $limit , $offset );
      $this-&gt;db-&gt;order_by('updated_on','desc');
  }
  $this-&gt;db-&gt;get('tablename');
  return  $this-&gt;db-&gt;result();
  }
  </code></pre>
  
  <p>Error Got</p>
  
  <pre><code>Not unique table/alias: 'table2'
  
      SELECT * FROM `tablename` JOIN `table2` ON `tablename`.`id` = `table2`.`id` JOIN `table2` ON `tablename`.`id` = `table2`.`id` WHERE `title` LIKE '%fashion%' OR `title` LIKE '%outlet%' ORDER BY `updated_on` DESC, `updated_on` DESC LIMIT 50
  </code></pre>