Welcome Guest, Not a member yet? Register   Sign In
Multiple Tables $query->result()
#1

[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
#2

[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");
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB