答案 0 :(得分:3)
使用union
select name from tableA
union
select name from tableB
答案 1 :(得分:1)
尝试一下
$tableA = $this->db->select('name')->get_compiled_select('tableA');
echo $tableA;
$tableB = $this->db->select('name')->get_compiled_select('tableB');
echo $tableB;
$tableAB = $this->get_compiled_select($tableA.' UNION '.$tableB);
echo $tableAB;
$query = $this->db->query($tableAB);
输出:
SELECT name FROM tableA
SELECT name FROM tableB
SELECT name FROM tableA UNION SELECT name FROM tableB
OR:
$query = $this->db->query("SELECT name FROM tableA UNION SELECT name FROM tableB");
答案 2 :(得分:1)
尝试一下
$result1 = $this->db->get('TableA');
$result2 = $this->db->get('TableB');
如果您只想合并特定的列,请使用select()
$this->db->select('name');
$result1 = $this->db->get('TableA');
$this->db->select('name');
$result2 = $this->db->get('TableB');
现在合并这两个记录
$combine = array_merge($result1, $result2);
详细了解array_merge()
答案 3 :(得分:0)
从TableA中选择名称,并从TableB中选择名称