簡體   English   中英

Codeigniter Active Record,在何處

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM