Welcome Guest, Not a member yet? Register   Sign In
Active record - same table multiple join?
#2

[eluser]cahva[/eluser]
What do you mean no way to alias joined tables?

Code:
$this->db->select('Orders.*, Billing.*, Delivery.*')
    ->from('Orders')
    ->join('CustomerAddresses Billing','Orders.BillingAddrID = Billing.ID','left')
    ->join('CustomerAddresses Delivery','Orders.DeliveryAddrID = Delivery.ID','left')
    ->where('Orders.ID',2);

..would produce:
Quote:SELECT `Orders`.*, `Billing`.*, `Delivery`.*
FROM (`Orders`)
LEFT JOIN `CustomerAddresses` Billing ON `Orders`.`BillingAddrID` = `Billing`.`ID`
LEFT JOIN `CustomerAddresses` Delivery ON `Orders`.`DeliveryAddrID` = `Delivery`.`ID`
WHERE `Orders`.`ID` = 2

Remember, to alias you dont need AS.


Messages In This Thread
Active record - same table multiple join? - by El Forum - 04-01-2010, 10:17 AM
Active record - same table multiple join? - by El Forum - 04-01-2010, 07:01 PM
Active record - same table multiple join? - by El Forum - 04-06-2010, 12:44 AM
Active record - same table multiple join? - by El Forum - 05-19-2010, 12:13 PM
Active record - same table multiple join? - by El Forum - 05-19-2010, 02:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB