我有一个运行正常的查询,但我不知道怎么写codeigniter
这是我的查询
SELECT id,contact,firstname,email
FROM `user`
WHERE `id` IN(SELECT id
FROM `hr`
WHERE `hr_id` IN(SELECT hr_id
FROM `admin_hr`
where id_admin_hr = 8)
) AND `id_category` =1
答案 0 :(得分:0)
您可以在where()
方法中添加子查询部分,试试这个
$this->db->select("id,contact,firstname,email")
->where("id IN(SELECT id FROM `hr` WHERE `hr_id` IN(SELECT hr_id FROM `admin_hr` where id_admin_hr = 8))")
->where("id_category", 1)
->get("user")