简体   繁体   English

Codeigniter Active Record,在何处

[英]Codeigniter Active Record, Where in

I have join table with where in I am wondering if there is a way i can say something like this :我有连接表,我想知道是否有办法可以这样说:

where kd_x in (select kd_x from master_code where a='11921212')

I'm trying to do this with active record like this but is doesn't give me any data我试图用这样的活动记录来做到这一点,但没有给我任何数据

$this->db->where_in('kd_x',array('select kd_x from MT_master where a="11921212"'));

Help me Please, Thank You请帮帮我,谢谢

->where() you can use 2nd and 3rd argument, so that any string you can pass ->where()您可以使用第二个和第三个参数,以便您可以传递任何字符串

$this->db->where('`kd_x`  IN (select `kd_x` from `MT_master` where a="11921212")', NULL, FALSE);

OR或者

//Create where clause
$this->db->select('kd_x')
         ->where('a','11921212')
         ->from('MT_master');
$where_clause = $this->db->get_compiled_select();

//Create main query
$this->db->select('*');
     ->from('your_table');
     ->where("`kd_x` IN ($where_clause)", NULL, FALSE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM