问题描述
它有2个查询连接在一起。
SELECT b.id,b.name FROM
(
SELECT
disTINCT min(a.id) as min_id
FROM table_a as a
JOIN table_b as b on b.table_a_id = a.id
JOIN table_c as c on c.table_b_id = b.id
WHERE c.id = '123'
AND a.delete_flg = 0
AND b.delete_flg = 0
AND c.delete_flg = 0
AND d.delete_flg = 0
) AS a
JOIN
(
SELECT
e.id,e.name
FROM table_e as e
WHERE e.delete_flg = 0
) as b
ON a.min_id = b.id
$query1 = $this->tableA->findAllByDeleteFlg(0)
->distinct()
->select([
'min_id' => 'min(tableA.id)'
])
->join([
'table' => 'table_b','alias' => 'tableB','type' => 'INNER','conditions' => 'tableB.table_a_id = tableA.id'
])
->join([
'table' => 'table_c','alias' => 'tableC','conditions' => 'tableC.table_b_id = tableB.id'
])
->where([
'tableC.id' => '123','tableA.delete_flg' => 0,'tableB.delete_flg' => 0,'tableC.delete_flg' => 0
]);
$query2 = $this->tableE->findAllByDeleteFlg(0)
->select([
'id' => 'tableE.id','name' => 'tableE.name',])
->where([
'tableE.delete_flg' => 0
]);
我对如何加入2 sql感到困惑。请帮忙。谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)