![]() |
Mulitple joins from same table - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Mulitple joins from same table (/showthread.php?tid=27729) |
Mulitple joins from same table - El Forum - 02-18-2010 [eluser]Quaotloa[/eluser] Hi, I have two addresses where I want to get the place in a query.. My query look like this now: $this->db->from('Customers'); $this->db->where('id', $id); $this->db->join('Zip_codes', 'Customers.delivery_zip = delivery.zip', 'left outer'); $query = $this->db->get(); But I want to do something like this: $this->db->from('Customers'); $this->db->where('id', $id); $this->db->join('Zip_codes', 'Customers.delivery_zip = delivery.zip', 'left outer'); $this->db->join('Zip_codes', 'Customers.invoice_zip = invoice.zip', 'left'); $query = $this->db->get(); But how can i seperate the result? If I only have one join to the table, I could do something like this; <?php echo $result->place; ?> But what do I do when I have two joins for the same table? I need to do something like: <?php echo $result->delivery.place; ?> <?php echo $result->invoice.place; ?> But I can't get it no work? Regards Fredrik Mulitple joins from same table - El Forum - 02-18-2010 [eluser]danmontgomery[/eluser] Code: $this->db->select('delivery.place AS delivery_place, invoice.place AS invoice_place'); |