CodeIgniter Forums
Multiple Tables $query->result() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Multiple Tables $query->result() (/thread-33824.html)



Multiple Tables $query->result() - El Forum - 09-09-2010

[eluser]Total Shop UK[/eluser]
How to I select data from a specific table?
I know $row->table1.name will not work but how should I do it?

Code:
$query = $this->db->query("SELECT * FROM table1 JOIN table2 ON table1.id=table2.id WHERE table1.id=1");
if ($query->num_rows()>0){
    foreach ($query->result() as $key => $row){
        $data['name'] = $row->table1.name;
    }
}

Cheers,
TSUK


Multiple Tables $query->result() - El Forum - 09-09-2010

[eluser]n0xie[/eluser]
Do you mean this?
Code:
$query = $this->db->query("SELECT table1.name FROM table1 JOIN table2 ON table1.id=table2.id WHERE table1.id=1");



Multiple Tables $query->result() - El Forum - 09-09-2010

[eluser]Total Shop UK[/eluser]
Thanks that was what I needed