CodeIgniter Forums
how to retrieve data from multiple table - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: how to retrieve data from multiple table (/showthread.php?tid=62942)



how to retrieve data from multiple table - nady - 09-09-2015

Hallo everybody...
i want to make a website like main category and sub category then content.

see the attachment.
Thanks in advance


RE: how to retrieve data from multiple table - Wouter60 - 09-09-2015

You can use "join" in the CI query builder. Like this:

PHP Code:
$this->db
->select('t1.maincat_name,t2.subcat_name')
->
from('categories t1')
->
join('subcategories t2','t2.cat_id = t1.id')
->
where('t1.maincat_name','Jokes');
$query $this->db->get(); 

For more information:
http://www.codeigniter.com/userguide3/database/query_builder.html?highlight=join#CI_DB_query_builder::join