everyone!
I have 2 tables: t1 and t2. They are almost the same (by column), but in different schemes s1 and s2.
So I need to create view from t1 if it not empty or from t2 (if t1 empty).
Example:
s1.t1. s2.t2
1 2
2 10
3 2
view:
1
2
3
Second:
s1.t1. s2.t2
<empty>. 1
2
9
View:
1
2
9
CodePudding user response:
The query could be
SELECT * FROM t1
UNION ALL
SELECT * FROM t2
WHERE NOT EXISTS (SELECT 1 FROM t1);