经典Oracle连接语法中的外连接

时间:2009-10-23 01:36:45

标签: sql oracle

我需要将我的查询转换为经典的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(+)

但我怎样才能包含“文字”条件?

1 个答案:

答案 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'