Re: Compare 2 fields in different tables using IF
I have finally managed to resolve my problem as follows:
-----------------
select 'various' from tour_det
inner join tour_hdr on tour_det.tourhdrid = tour_hdr.id
inner join diet_anal on diettour_id = tour_det.id and diettour_type = 'TourDet' and tour_hdr.paxno != tour_det.paxno
OR
diettour_id = tour_hdr.id and diettour_type = 'TourHdr' and tour_hdr.paxno = tour_det.paxno
-----------------
There were 2 things that I didn't know about joins which I've learnt.
1. You can use an OR clause to define different join conditions. However by itself that is not enough because when the diet_anal table has entries for both the tour_hdr and tour_det then both sets are included.
2. You can use fields that are not in any of the join tables but available in the query to define additional conditions.
I hope this information proves useful to someone else.
Subject
Written By
Posted
February 16, 2018 06:31AM
February 16, 2018 09:07AM
February 16, 2018 09:19AM
February 16, 2018 09:21AM
February 16, 2018 09:51AM
February 16, 2018 11:58AM
February 19, 2018 03:38AM
Re: Compare 2 fields in different tables using IF
February 19, 2018 05:17AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.