如何解决如何在Codeigniter查询构建器中使用“ UNION”?
我正在使用codeigniter query-builder运行查询:
$this->db->select('t_heatpad.heatpad_status,t_heatpad.idheatpad,t_heatpad.heatpad_firstname,t_heatpad.heatpad_lastname,t_heatpad.heatpad_address,t_heatpad.heatpad_phone,t_heatpad.heatpad_doc_firstname,t_heatpad.heatpad_doc_lastname,t_heatpad.heatpad_doc_npi,t_heatpad.heatpad_doc_phone,t_heatpad.heatpad_doc_fax,t_heatpad.heatpad_med_id,t_heatpad.heatpad_data_entered,t_heatpad.heatpad_global ');
$this->db->from('t_heatpad');
$subQuery4 = $this->db->get_compiled_select();
$this->db->select('t_cgm_diabetic.cgmdiab_status,t_cgm_diabetic.idcgmdiab,t_cgm_diabetic.cgmdiab_firstname,t_cgm_diabetic.cgmdiab_lastname,t_cgm_diabetic.cgmdiab_address,t_cgm_diabetic.cgmdiab_phone,t_cgm_diabetic.cgmdiab_doc_firstname,t_cgm_diabetic.cgmdiab_doc_lastname,t_cgm_diabetic.cgmdiab_doc_npi,t_cgm_diabetic.cgmdiab_doc_phone,t_cgm_diabetic.cgmdiab_doc_fax,t_cgm_diabetic.cgmdiab_medicare,t_cgm_diabetic.cgmdiab_date_entered,t_cgm_diabetic.cgmdiab_global ');
$this->db->from('t_cgm_diabetic');
$subQuery5 = $this->db->get_compiled_select();
现在,我要在$ subQuery4和$ subQuery5上加入并集。
这种方法对我来说很好:
$this->db->query("select * from ($subQuery4 UNION $subQuery5 ) as unionTable");
但是我想用这种格式:
$this->db->select('*');
$this->db->from("($subQuery4 UNION $subQuery5 )");
$this->db->get();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。