在这里,我有两个名为main_tableand的表main_table_replica。main_table_replica是 的复制品main_table。但问题是我可以在main_table或中找到数据main_table_replica。现在我正在做如下查询。我怎样才能避免在这里联合?在这两个查询中,唯一的变化是main_tableand main_table_replica。
SELECT DISTINCT e.some_id
FROM
main_table e, //Change is here
main_table_join_one x
where e.some_id = x.some_id(+)
and (x.status in('A','I') or x.status is null)
and e.code='XYZ' and e.second_code in('XYZ','ABC')
UNION
SELECT DISTINCT t.some_id
FROM
main_table_replica t, //Change is here
main_table_join_one xf
where t.some_id = xf.some_id(+)
and (xf.status in('A','I') or xf.status is null)
and t.code='XYZ' and t.second_code in('XYZ','ABC')
谢谢!