以下连接是否在MySQL中有效
$this->db->select('A.plan_prepared_by,A.approval_date, U.display_name');
$this->db->from('A');
$this->db->where('plan_id', $planid );
$this->db->join('U','U.id=A.approval_user_id','left');
$this->db->join('U','U.username =A.plan_prepared_by','left');
答案 0 :(得分:1)
您可以通过添加别名
来尝试这样做$select = array(
'A.plan_prepared_by',
'A.approval_date',
'UL.display_name'
);
$where = array(
'plan_id' => $planid
);
$this->db->select($select);
$this->db->from('A');
$this->db->where($where);
$this->db->join('U AS UL','UL.id = A.approval_user_id','left');
$this->db->join('U AS UR','UR.username = A.plan_prepared_by','left');