Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何在codeigniter中为3 where_in()编写查询_Mysql_Codeigniter - Fatal编程技术网

Mysql 如何在codeigniter中为3 where_in()编写查询

Mysql 如何在codeigniter中为3 where_in()编写查询,mysql,codeigniter,Mysql,Codeigniter,我有一个运行正常的查询,但我不知道如何在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`

我有一个运行正常的查询,但我不知道如何在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

您可以在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")