dimanche 25 novembre 2018

How to use CASE or IF-staitment in Postgres to select from different table?

I want to make a selection from one of many tables. This selection depends on some condition. How can I make it? I suppose it should be some like this (but it doesn't work):

CASE x
    WHEN x=1 THEN
       select Id,Name from table1
    WHEN x=2 THEN
       select Id,Name from table2
    WHEN x=3 THEN
       select Id,Name from table3
END CASE;

Aucun commentaire:

Enregistrer un commentaire