[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

subqueries - general link/tutorial for syntax etc..

CharlesA

3/22/2007 1:58:00 PM

Hi folks,
I'm using sql server 2005 standard edition but this isn't highly pertinent
except to say that it's Transact-SQL that I'm interested in

I'm fine with SQL in general but my weakness is subqueries (correlated or
otherwise) there seems to be an almost bewildering array of ways of deploying
them

is there any comprehensive links on the internet that you know about that
could really help me from the ground up to know what is legal and not legal
in the major types of subquery (and then in due course, I will combine and
mix and match them to do what I'm trying to do).

my question I suppose is, do you know of a really decent and thorough
discussion of what syntaxes are possible in which clauses and whether they
are optimal or desirable etc...


one final question.
is elaborate subquerying desirable or should I find different ways of
solving my data fetching problems (using temp tables etc...)

regards and many thanks in advance for your time,
CharlesA
2 Answers

Uri Dimant

3/22/2007 2:09:00 PM

0

Hi
Conceptually, a correlated subquery is similar to loop in programming.The
result of each execution of the subquery must be correlated to a row of the
main table.

http://www.sql.co.il/books/insid...







"CharlesA" <CharlesA@discussions.microsoft.com> wrote in message
news:43FF00A6-DD77-4FBE-AED2-2AF377D766FE@microsoft.com...
> Hi folks,
> I'm using sql server 2005 standard edition but this isn't highly pertinent
> except to say that it's Transact-SQL that I'm interested in
>
> I'm fine with SQL in general but my weakness is subqueries (correlated or
> otherwise) there seems to be an almost bewildering array of ways of
> deploying
> them
>
> is there any comprehensive links on the internet that you know about that
> could really help me from the ground up to know what is legal and not
> legal
> in the major types of subquery (and then in due course, I will combine and
> mix and match them to do what I'm trying to do).
>
> my question I suppose is, do you know of a really decent and thorough
> discussion of what syntaxes are possible in which clauses and whether they
> are optimal or desirable etc...
>
>
> one final question.
> is elaborate subquerying desirable or should I find different ways of
> solving my data fetching problems (using temp tables etc...)
>
> regards and many thanks in advance for your time,
> CharlesA


Hugo Kornelis

3/23/2007 11:42:00 PM

0

On Thu, 22 Mar 2007 06:58:20 -0700, CharlesA wrote:

(snip)
>is there any comprehensive links on the internet that you know about that
>could really help me from the ground up to know what is legal and not legal
>in the major types of subquery (and then in due course, I will combine and
>mix and match them to do what I'm trying to do).

Hi Charles,

I don't think that a broad topic as this can be effectively learned
through internet. I'd recommend that you go to a goood book store, leaf
through a couple of books on query writing and pick one or two that best
fit your preferred style of reading/learning. The Inside SQL Server
boooks that Uri refers to are excellent, but probably a bit too advanced
for the beginning SQL developer.

>one final question.
>is elaborate subquerying desirable or should I find different ways of
>solving my data fetching problems (using temp tables etc...)

In almost all cases, combining the logic into a single query yields
better performance than breaking it down into substeps. And yes, that
single query will often involve subqueries.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hug...