Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging multiple oracle queries to produce one result

Tags:

sql

join

oracle

Is it possible to execute the following query as one query?

[code]

select count(*) from tableA;
select count(*) from tableB;
select count(*) from tableC;
select count(*) from tableD;

[/code]

ie. the result to be something like this

|TablA|TableB|TableC|TableD|
|50   |300   |30    |9|

Thanks

like image 281
ziggy Avatar asked May 05 '11 14:05

ziggy


2 Answers

select * from
(select count(*) from tableA),
(select count(*) from tableB),
(select count(*) from tableC),
(select count(*) from tableD);
like image 126
John Avatar answered Sep 20 '22 15:09

John


Yes

select count(*) from tableA;
union all
select count(*) from tableB;
union all
select count(*) from tableC;
union all
select count(*) from tableD; 
like image 26
xkonnectDeveloper Avatar answered Sep 20 '22 15:09

xkonnectDeveloper