sql - Alternate solution for the query - Used INTERSECT function in oracle plsql -
i working on query. have 2 tables 1 detail table not grouping happen , including values , other table line table has important column grouped detail table.
i want show column line table , column detail table.
i using below query fetch records
select ab.*, cd.phone_number, cd.id xxx_line ab, xxx_detail cd cd.reference_number = ab.reference_number , cd.org_id = ab.org_id , cd.request_id = ab.request_id , ab.request_id = 13414224 intersect select ab.*, cd.phone_number, cd.id xxx_line ab, xxx_detail cd cd.reference_number = ab.reference_number , cd.org_id = ab.org_id , cd.request_id = ab.request_id , ab.request_id = 13414224 the query working fine...
but want know there other way can achieve same result not using intersect.
i purpose find out possible way same output.
the intersect operator returns unique set of rows returned each query. code can re-written distinct operator make meaning clearer:
select distinct xxx_line.*, xxx_detail.phone_number, xxx_detail.id xxx_line join xxx_detail on xxx_line.reference_number = xxx_detail.reference_number , xxx_line.org_id = xxx_detail.org_id , xxx_line.request_id = xxx_detail.request_id xxx_line.request_id = 13414224 i replaced old-fashioned join syntax newer ansi join syntax (which makes relationships clearer forcing join tables , conditions listed close each other) , removed meaningless table aliases (because code complexity more directly related number of variables number of characters).
Comments
Post a Comment