Difference between a sub-query and a nested query?

Can anybody give the best exaplanation for the diffrence between sub-query and nested query?

more ▼

asked Mar 18, 2010 at 03:34 PM in Default

venkatreddy gravatar image

562 29 29 32

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

As grant says, the things you have mentioned are one and the same.

You basically have:

A sub-query - this is a query which is used as part of a larger query. Much as you would select from a table, you can select from a sub-query.

A correlated sub-query - this is a particular type of sub-query that references the outer query - it's used for exists, having etc.

A scalar sub-query - this is where you use a sub-query more like a column - to pick up a single value from somewhere.

Hope that helps...

more ▼

answered Mar 18, 2010 at 05:38 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

is it that,nested query executes for more numebr of times within a sub-query?
Mar 19, 2010 at 06:57 AM venkatreddy
For extra credit...what is so special about a nested query that it deserves its own explicit linked server property? Allowing a recursive cte seems more apposite for first-class citizenship
Mar 19, 2010 at 08:03 AM Scot Hauder
(comments are locked)
10|1200 characters needed characters left

To my knowledge, that's two terms for the same concept.

more ▼

answered Mar 18, 2010 at 03:43 PM

Grant Fritchey gravatar image

Grant Fritchey ♦♦
103k 19 21 74

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Mar 18, 2010 at 03:34 PM

Seen: 4262 times

Last Updated: Mar 19, 2010 at 05:03 AM