question

venkatreddy avatar image
venkatreddy asked

Difference between a sub-query and a nested query?

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

t-sqlhomeworksub-querysubjective
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered

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...

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image
Grant Fritchey answered

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

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.