Monday, March 26, 2012

Parent/child SQL query

Hello, I woud like to find a resource (book, web site, etc.) that
demonstrates writing queries related to parent/child relationships. In
particular I have a table that contains an unknown number of parents/childre
n
(and grand-children, great grand children, etc). I would like to create a
pivot table so that all the parents become columns and each row represents a
child (grand child, great grand child, etc.) for that parent.
Thank you,
RicOne of them is "Trees and Hierarchies" by Joe Celko. I'm sure he's just
writing a response himself. ;)
However, what you've specified in your post is best handled on the client,
as it's obviously just for presentation purposes (it breaks nromalization).
ML
http://milambda.blogspot.com/|||>> I woud like to find a resource (book, web site, etc.) that demonstrates w
riting queries related to parent/child relationships.<<
Buy a copies of TREES & HIERARCHIES IN SQL, of course! Steral the code
in the book.|||Check out the stuff Izik Ben Gan has done on trees and hierarchies.
Don't buy celko's book, its based around standard sql rather than Microsoft
SQL Server so you'll find it hard to implement, also, a lot of his methods
are slow, dont scale and out of date.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"Ric" <Ric@.discussions.microsoft.com> wrote in message
news:CB71D7E5-0534-404B-8787-1F2F527F0D0A@.microsoft.com...
> Hello, I woud like to find a resource (book, web site, etc.) that
> demonstrates writing queries related to parent/child relationships. In
> particular I have a table that contains an unknown number of
> parents/children
> (and grand-children, great grand children, etc). I would like to create a
> pivot table so that all the parents become columns and each row represents
> a
> child (grand child, great grand child, etc.) for that parent.
> Thank you,
> Ric|||"Tony Rogerson" <tonyrogerson@.sqlserverfaq.com> wrote in message
news:OEbv0ykIGHA.3896@.TK2MSFTNGP15.phx.gbl...
> Check out the stuff Izik Ben Gan has done on trees and hierarchies.
Yes, but why isn't there dedicated sql for this?
Even if they had to use xml? :)
I know, it's a high priority for a future release......Please:):(

> Don't buy celko's book, its based around standard sql rather than
> Microsoft SQL Server so you'll find it hard to implement, also, a lot of
> his methods are slow, dont scale and out of date.
Yes, but why is it so popular on this ng?
Required reading according to many of the experts!
The twilight is blinding...:)
www.rac4sql.net|||>> Yes, but why isn't there dedicated sql for this? Even if they had to use
xml? :) <<
Recursive CTE expressions are now a part of Standard SQL. I like CTEs
but I do not like the recursirve version -- it seldom used so it
destorts the engine and it is a screaming XXXXX to optimize.
You silly boy! Because this book is the brilliant work of a known SQL
genius, who is kind to animals, God's gift to strippers as well as
undergrad math students, and so much nicer in person than on
Newsgroups!! Soon to be listed on a webite for sainthood ..
Seriously, if you cannot translate Standard SQL into any product
dialect, then you are a truly bad SQL programmer. This is like saying
"I only speak Hillbilly English and cannot leave my ghetto!"
"Caesar: Pardon him, Theodotus. He is a barbarian and thinks the
customs of his tribe and island are the laws of nature." - Caesar and
Cleopatra; George Bernard Shaw 1898|||> ...God's gift to strippers as well as
> undergrad math students...
Geez! LOL :)

> Soon to be listed on a webite for sainthood...
Be sure to post the link. ;)
ML
http://milambda.blogspot.com/|||>> > Soon to be listed on a website for sainthood...Be sure to post the link
. ;) <<
Well, first, I have to get the domain registered ...

No comments:

Post a Comment