[英]Codeigniter Active Record, Where in
我有连接表,我想知道是否有办法可以这样说:
where kd_x in (select kd_x from master_code where a='11921212')
我试图用这样的活动记录来做到这一点,但没有给我任何数据
$this->db->where_in('kd_x',array('select kd_x from MT_master where a="11921212"'));
请帮帮我,谢谢
->where()
您可以使用第二个和第三个参数,以便您可以传递任何字符串
$this->db->where('`kd_x` IN (select `kd_x` from `MT_master` where a="11921212")', NULL, FALSE);
或者
//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.