Ask Your Question

How can an if statement be incorporated to choose a table within the FROM statement in ORACLE?

asked 2022-09-18 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-05-27 20:00:00 +0000

ladyg gravatar image

You can use a conditional expression within the FROM statement to choose a table based on a condition, such as an IF statement. Here is an example:

SELECT * FROM (IF somecondition THEN table1 ELSE table2 END IF) WHERE somecolumn = 'some_value';

In this example, the IF statement checks a condition and selects either table1 or table2 to be used in the FROM clause. The WHERE clause is then applied to the selected table. Keep in mind that this example is not valid ORACLE syntax but having similar condition syntax can be used.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2022-09-18 11:00:00 +0000

Seen: 1 times

Last updated: May 27 '22