是否可以纠正此查询

`$sql = '
    SELECT *
    FROM employers
    LEFT JOIN jobwall ON jobwall.employers_employer_id = employers.employer_id
    WHERE employers.employer_id
    IN (SELECT employers_employer_id FROM jobwall)
';

$this->db->query($sql);`


作为代码记录器中的活动记录

最佳答案

我同意Joe Stefanelli的观点,对于普通联接来说,不需要LEFT JOIN和WHERE IN子查询。以下应该做您想要的:

$this->db->join('jobwall'
    , 'jobwall.employers_employer_id = employers.employer_id');
$this->db->get('employers');


仅当您想获得所有雇主(无论他们是否在工作表中)时,才使用LEFT JOIN。

关于php - 更改mysql,其中查询到codeigniter事件记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4599103/

10-12 12:28