x
login about faq Site discussion (meta-askssc)

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 '10 at 03:34 PM in Default

venkatreddy gravatar image

venkatreddy
562 26 28 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 '10 at 05:38 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

is it that,nested query executes for more numebr of times within a sub-query?

Mar 19 '10 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 '10 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 '10 at 03:43 PM

Grant Fritchey gravatar image

Grant Fritchey ♦♦
64.9k 13 20 66

(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

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x916
x69
x45
x21

asked: Mar 18 '10 at 03:34 PM

Seen: 3231 times

Last Updated: Mar 19 '10 at 05:03 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.