lundi 16 avril 2018

Join tables with if-conditions

I am building a view called MAIN_VIEW in Oracle and this view has many join conditions. Among them, it has two particular join conditions with the following views: FIRST_VIEW (on MAIN_VIEW.ID1 = FIRST_VIEW.ID) and SECOND_VIEW (on MAIN_VIEW.ID2 = SECOND_VIEW.ID) but these join conditions should be applied only if FIRST_VIEW.ID and SECOND_VIEW.ID exist in the FIRST_VIEW and in the SECOND_VIEW respectively. Furthermore, if the FIRST_VIEW.ID exists, then I should check other conditions in the FIRST_VIEW (and only in that case, meaning only when the join can be applied).
Is there a way to create such a thing using, for example an IF clause in the WHERE condition of the MAIN_VIEW?

Aucun commentaire:

Enregistrer un commentaire