Welcome Guest, Not a member yet? Register   Sign In
Mulitple joins from same table
#1

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

[eluser]danmontgomery[/eluser]
Code:
$this->db->select('delivery.place AS delivery_place, invoice.place AS invoice_place');




Theme © iAndrew 2016 - Forum software by © MyBB