mysql - 如何在codeigniter中联合查询?
问题描述
我尝试使用这个
$this->db->select('title, content, date');
$this->db->from('mytable');
$query = $this->db->get();
$subQuery1 = $this->db->_compile_select();
$this->db->_reset_select();
$this->db->select('title, content, date');
$this->db->from('mytable2');
$query = $this->db->get();
$subQuery2 = $this->db->_compile_select();
$this->db->_reset_select();
$sql = ("$subQuery1 UNION $subQuery2");
$rowsdata = $this->db->query($sql)->result_array();
print_r($rowsdata);
die();
当我使用 print_r(); 查看数组结果,但什么也没发生。
解决方案
推荐阅读
- laravel - 无法在 Ubuntu 16.04 中安装 laravel
- json - Post intents using Dialogflow V2 REST API
- javascript - jQuery 在 Firefox 和 Safari 中不起作用
- javascript - JetBrains GoLand permanently loosing version control state: need manual refresh on any change
- python - How can I get the previous source code line number which calls logging in-directly?
- excel - 将英国日期复制成美国格式
- javascript - JavaScript 正则表达式到 PHP 正则表达式
- mysql - 如何在 Sequelize 中获取更新行的字段和值
- php - 将jquery ajax结果插入html表单
- c++ - 继承 libsourcey 库中的信号