creating view based on availability of data in 2 tables [message #628579] |
Wed, 26 November 2014 06:08 |
|
raja.i
Messages: 11 Registered: November 2014
|
Junior Member |
|
|
Having the situation like this. Actually have to create one view and it based on following conditions
1.Two tables are there, consider t1 and t2.
2.If t1 contains the data, then i have to create the view based on datas from t1, i.e(select * from t1)
3.If no data in t1 then select * from t2.
Please guys help me to write a sql query to create the view
help me as sn as possible
|
|
|
|
Re: creating view based on availability of data in 2 tables [message #628584 is a reply to message #628581] |
Wed, 26 November 2014 06:18 |
|
Littlefoot
Messages: 21807 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Whoa, what an impatient person! Do you really think that forum community has nothing to do but answer your questions?
Anyway: here's an idea, see what you can do with it:
select col from t1
where not exists (select 'x' from t2)
union all
select col from t2
where not exists (select 'x' from t1);
P.S. You didn't say what you want to do when both T1 and T2 contain data.
[Updated on: Wed, 26 November 2014 06:19] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|