Mysql 如何使用;“工会”;在codeigniter查询生成器中?
我正在使用codeigniter查询生成器运行查询:Mysql 如何使用;“工会”;在codeigniter查询生成器中?,mysql,sql,codeigniter,union,query-builder,Mysql,Sql,Codeigniter,Union,Query Builder,我正在使用codeigniter查询生成器运行查询: $this->db->select('t_heatpad.heatpad_status, t_heatpad.idheatpad, t_heatpad.heatpad_firstname, t_heatpad.heatpad_lastname, t_heatpad.heatpad_address, t_heatpad
$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上加上union。这种方法对我很有效:
$this->db->query("select * from ($subQuery4 UNION $subQuery5 ) as unionTable");
但我想用这种形式来做:
$this->db->select('*');
$this->db->from("($subQuery4 UNION $subQuery5 )");
$this->db->get();
请不要将代码和错误消息作为图像发布,而是作为代码格式的文本发布,因为我们都无法复制、粘贴和运行图像。有关这方面的更多信息,请在提问时参见?。另外,请查看以了解更多的现场最佳实践。感谢提供此信息…np,但请将错误消息作为文本放在您的问题中!