[thelist] basic SQL many-many optimization

Tab Alleman Tab.Alleman at MetroGuide.com
Thu Jul 17 08:23:00 CDT 2003


rudy wrote:

> piece-of-cake do-it-in-yer-sleep one-hand-tied-behind-your-back 

> in other scripting languages, you gotta do the "current/previous"
> logic yourself

>   set previoustitle = ''   /* empty */
>   while not eof
>      get next record
>      if currenttitle > previoustitle
>         print title on new line
>         set previoustitle = currenttitle
>      print genre on same line

Well yeah, anybody can do it in the middleware..I was thinking there
must be a sql-magic method, but my brain hurt when I tried to think of
one.

Just remember if you do it this way, to put "ORDER BY TitleID, GenreID"
in your SELECT query (in case that wasn't obvious enough already).


More information about the thelist mailing list