私は100%ではありませんあなたが何を必要としているか理解しています。しかし、私はあなたがこれを行うために組合を使うことができると思います:
create table theValues ( theValue integer)
create table table1 ( value1 integer)
create table table2 ( value2 integer)
INSERT INTO theValues (thevalue) VALUES (2)
INSERT INTO table1 ( value1 ) VALUES (17)
INSERT INTO table2 ( value2 ) VALUES (8)
SELECT value1 from table1 WHERE EXISTS (SELECT theValue from theValues WHERE theValue != 2)
UNION ALL
SELECT value2 from table2 WHERE EXISTS (SELECT theValue from theValues WHERE theValue = 2)
この場合、「マジックナンバー」は2です。Valuesテーブルクエリが2を返す場合は、table2の結果から結果を取得します。それ以外の場合は、テーブル1の結果を取得します。
乾杯、ダニエル