有2张桌子:
orders:
id requester_id supplyer_id status
1 423 1 reserved
2 500 1 supplied
3 222 2 reserved
...
users
id username register_date
1 admin 2012-01-01
2 smith 2013-01-01
...
423 John 2012-10-11
500 Doe 2012-12-11
222 name 2012-10-13
...
我想加入这两个表并得到这个结果
id requester_username supplier_username status
1 John admin reserved
2 Doe admin supplied
3 name smith reserved
我实际上可以使用活动记录加入这些表,例如:
$this->db->select('orders.*,users.username')
->from('orders')
->join('users','users.id = orders.requester_id')
->get()->result();
但我不知道如何同时获得supplier username
。