CodeIgniter Forums

Full Version: active query question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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.

El Forum

[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();

El Forum

[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().

El Forum

[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

El Forum

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

El Forum

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