Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Selecting Multiple columns in Sub-query

MKMay 18 2011 — edited May 18 2011
Hi All,

I've been using three co-related queries to fetch data as shown below in the pseudo code. All these sub-queries are same, except the column name. I want to avoid the same query to be executed thrice for three columns. Is there any way to avoid this?
insert into my_table 
select colA, 
colB,
(select field1 from table1 where table1.fieldx =tableA.fieldy ) col1,
(select field2 from table1 where table1.fieldx =tableA.fieldy) col2,
(select field3 from table1 where table1.fieldx =tableA.fieldy) col3
 from tableA , table B  
where con1= con2 
    and con3 = con4 
    and con4=con5;
All suggestions are welcomed

Regards,
K
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2011
Added on May 18 2011
2 comments
3,288 views