我需要将我的查询转换为经典的Oracle连接语法,因为我需要将它放在物化视图中。但是,我不太清楚如何做到这一点:
SELECT * FROM transactions t
LEFT JOIN transac_detail td1 ON (t.id = t1.trans_id AND t.ttype = 'VOICE')
LEFT JOIN transac_detail td2 ON (t.id = t2.trans_id AND t.ttype = 'BROADBAND');
我开始这样写:
SELECT * FROM transactions t, transac_detail td1, transac_detail td2
WHERE t.id = t1.trans_id(+) AND t.id = t2.trans_id(+)
但我怎样才能包含“文字”条件?
答案 0 :(得分:0)
原始查询困惑。你是说这个吗?
SELECT t.* FROM transactions t, transac_detail td1
WHERE t.id = td1.trans_id(+)
and t.ttype = 'VOICE'
union
SELECT t.* FROM transactions t, transac_detail td2
WHERE t.id = td2.trans_id(+)
and t.ttype = 'BROADBAND'