title: display multiple categories codeigniter
body: <p>I have a relational database in this format</p>
  
  <pre><code>Table: posts
  Columns: post_id,post_title,post_content
  
  Table: categories
  Columns: category_id,category_name
  
  Table: posts_categories
  Columns: post_id,category_id
  </code></pre>
  
  <p>Posts can have multiple categories so i store them in posts_categories using post and category id, when i get results from database using below query, it just display the last category, Is it possible to display all categories otherwise i have to run a separate query, here my code.</p>
  
  <pre><code>    $this-&gt;db-&gt;select("p.*,pc.*,c.*");
      $this-&gt;db-&gt;where('post_id', $id); 
      $this-&gt;db-&gt;from('posts AS p');
      $this-&gt;db-&gt;join('posts_categories AS pc', 'pc.post_id = p.post_id', 'inner');
      $this-&gt;db-&gt;join('categories AS c', 'pc.category_id = c.category_id', 'inner');
      $q = $this-&gt;db-&gt;get();
  </code></pre>
  
  <p>Thanks for any help.</p>