CodeIgniter Forums
active query question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: active query question (/showthread.php?tid=25817)



active query question - El Forum - 12-27-2009

[eluser]xeroblast[/eluser]
hello,

how can i use this query (SELECT * FROM `table1`,`table2` WHERE `table1`.`id`=`table2`.`table1_id` AND `table2`.`id`='my_value') using the active query?

thanx.


active query question - El Forum - 12-27-2009

[eluser]umefarooq[/eluser]
Code:
$this->db->select('*');
$this->db->from('table1');
$this->db->form('table2'); modified
$this->db->where('table1.id = table2.table1_id');
$this->db->where('table2.id',my_value);
$query = $this->db->get();



active query question - El Forum - 12-27-2009

[eluser]xeroblast[/eluser]
thanx for the reply...

do you think $this->db->from() can accommodate 2 tables?

i only use the $this->db->join() but cant accommodate the $this->db->where().


active query question - El Forum - 12-27-2009

[eluser]umefarooq[/eluser]
yes from can do but join is best option for tables to retrieve records between tables where you can use for specific record


active query question - El Forum - 12-27-2009

[eluser]xeroblast[/eluser]
thank you...


active query question - El Forum - 01-03-2010

[eluser]iron-man[/eluser]
You can use $this->db->join(); command