Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Where Clause in a Subquery Vs the parent query

Author  Topic 

sagittarian82
Starting Member

2 Posts

Posted - 2012-08-06 : 10:58:19
I have a select query on Table A and the join is using a subquery which again uses Table A along with another table B. I need to add a couple of where clauses on Table A. Where should I add the clauses? In the subquery or in the parent query? Which will perform well? Thanks in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-06 : 11:01:01
if its inner join its enough to add it only to subquery. if its left join you might want to add it to main query or subquery based on requirement. if condition is required for matching alone use inside subquery and if you want filter to be applied in any case add it in main query

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sagittarian82
Starting Member

2 Posts

Posted - 2012-08-06 : 16:39:26
Thanks!
Go to Top of Page
   

- Advertisement -