0
我有3個表,我想加入它們。如果這三個領域有一個類似的領域,那很容易。問題是,table1和table2有一個類似的字段,table2和table3有另一個類似的字段,但是沒有類似的字段可以連接table1和table3。我嘗試使用下面的代碼加入他們,但它不起作用。我得到一個錯誤的那場「branch_name」未定義:在codeigniter中加入更多的2個表,沒有公共字段
$this->db->select('r.*,
b.id as branch_id,
b.name as branch_name');
$this->db->join('users_branches AS ub', 'ub.user_id = r.user_id');
$this->db->join('branches AS b', 'b.id = ub.branch_id');
$this->db->where('payroll_period_id',$payroll_period_id);
return $this->db->get('dtr r');
是否有任何解決這個?