469,126 Members | 1,280 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

query

1
hi everyone

i am trying to join three tables(2 same tables and one different table) and it is taking very long time

here is the query
can anyone optimize the query as it is taking very long time to run

i have 2 tables
tablea
tableb

select * from tablea a1 inner join (select * from tableb where condition) a3
on a1.col1=(select max(col1) from tablea a2
where a3.col2=a2.col2)


i am running this same query based on a condition with col2 and it is working fine and i was using only tables a1 and a3 once.

any suggestions welcome
thanks
Mar 6 '07 #1
3 945
hariharanmca
1,977 1GB
hi everyone

i am trying to join three tables(2 same tables and one different table) and it is taking very long time

here is the query
can anyone optimize the query as it is taking very long time to run

i have 2 tables
tablea
tableb

select * from tablea a1 inner join (select * from tableb where condition) a3
on a1.col1=(select max(col1) from tablea a2
where a3.col2=a2.col2)


i am running this same query based on a condition with col2 and it is working fine and i was using only tables a1 and a3 once.

any suggestions welcome
thanks
Can u explain your Requirement, then its easy to give sugges
Mar 7 '07 #2
hi everyone

i am trying to join three tables(2 same tables and one different table) and it is taking very long time

here is the query
can anyone optimize the query as it is taking very long time to run

i have 2 tables
tablea
tableb

select * from tablea a1 inner join (select * from tableb where condition) a3
on a1.col1=(select max(col1) from tablea a2
where a3.col2=a2.col2)


i am running this same query based on a condition with col2 and it is working fine and i was using only tables a1 and a3 once.

any suggestions welcome
thanks
try

Select (all coulmsn from table a)(all columns from table b) from tablea a1 inner join tableb a2 on a1.col = a2.col
where a1.col in (select max(col1) from tablea a2 where a3.col = a2.col)

I was laso wondering if two of the tables are same and have the same data then in might be feasable just to use a1 instaed of a3 in the subquery
Mar 7 '07 #3
scripto
143 100+
This is probably what you want

select * from tablea a1 where a1.col1 = (
select max(col1) from tablea a2 inner join (select * from tableb where condition) a3 on a3.col2=a2.col2 )
Mar 7 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
14 posts views Thread by Dave Thomas | last post: by
4 posts views Thread by Stan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.