Sathish
Sathish

Reputation: 4487

select same table in multiple schema's without using union all

Schema Name's: A,B

Both schema have same Table :

Table Name: stock. Feilds no,Stname

I want retrive details from stock table in two schams.

So i use this query :

 select no,stname from A.stock union all select no,stname from B.stock

I want to get the tables detail with out union all. Is it possible ? How to do that ?

I am using postgresql 9.0

Upvotes: 0

Views: 1539

Answers (1)

Houari
Houari

Reputation: 5651

Here is how you view looks like:

CREATE OR REPLACE VIEW union_of_my_stock_tables AS 
 select no,stname from A.stock 
 union all 
 select no,stname from B.stock;
union all 
 select no,stname from C.stock;
union all 
 select no,stname from D.stock;

And in your project you can query this view by:

select * from union_of_my_stock_tables;

Upvotes: 1

Related Questions