Я выполняю запрос с помощью построителя запросов 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.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();
Подробнее здесь: https://stackoverflow.com/questions/639 ... get-compil