0

以下连接在 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');
4

1 回答 1

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');
于 2013-05-24T09:11:52.330 回答