In the Oracle DB there are three tables, see below.
Here is a Fiddle with data to test : http://sqlfiddle.com/#!4/d7cb4
Depending on the result of a query from the 'People' table, how can I proceed with a different query to request data further either from 'Dogs' or 'Cats'.
Simply saying I need to execute a corresponding query depending on the answer of the initial/main query. Here is what I tried, (which obviously does not work):
<!-- language: sql --> WITH CONDITION_CHECK AS ( SELECT ADORE FROM PEOPLE WHERE ADORE = 'dog' --here I will put my variable ) SELECT CASE WHEN CC.ADORE = 'dog' THEN (SELECT * FROM DOGS) WHEN CC.ADORE = 'cat' THEN (SELECT * FROM CATS) ELSE NULL END FROM CONDITION_CHECK AS CC
What is the most common approach to set up a conditional statement in Oracle DB? And how can one execute it?
I have seen the IF-THEN-ELSE Statement, but I do not understand it much.