0

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

4
  • Can i ask you why you want to avoid union all? Commented Feb 28, 2014 at 9:43
  • @Houari Sir in my real if i am using its create a big query like my query size is 9 page in msword. if i connect the multiple schemas in single query is reduce the query in my project Commented Feb 28, 2014 at 9:46
  • What about creating a view that bring you those union all of all your stock tables, and in your project you have to just select query this view ? Commented Feb 28, 2014 at 9:50
  • i use select query only sir. And my some time my table have same no or same stname. And how to use view in this case sir @Houari Commented Feb 28, 2014 at 9:53

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks Sir. If i want my multiple tables combine in my query then i must create multiple view ah Sir?
How much cominaison do you have ?
i have more than 5 tables in multiple schema's
No, i'm talking about your combinaisons!?
Sorry sir i Can't understand?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.