1

I have two queries for the same task

ONE:

select * from table1 t1 
INNER JOIN table2 t2 
ON t1.id=t2.id

TWO

select * from table1 t1 
INNER JOIN (select * from table2) t2 
ON t1.id=t2.id

I checked the execution plan for both the queries.Both execution plans are same.But i doubt ,is there any difference in both the queries? If yes which one is more efficient?

gkarya42
  • 429
  • 6
  • 22

1 Answers1

1

There is no difference. You don't have any extra conditions in inner query. It is a straight select from table. Same happens in the background.

Sateesh Pagolu
  • 9,282
  • 2
  • 30
  • 48
  • what if my query is like... select * from table1 t1 INNER JOIN (select col1,col2 from table2 where 'Some condition') t2 ON t1.id=t2.id ..then which one is better – gkarya42 Sep 18 '15 at 05:04
  • @gkarya42 : Placement of condition doesn't matter in case of inner join. So, they are same. For better readability, use `Table1 INNER JOIN table2 ON AllConditionsHere` – Sateesh Pagolu Sep 18 '15 at 05:21