[thelist] Problem with SQL Query - using PHP and MySQL

Matt Warden mwarden at gmail.com
Mon Nov 13 16:43:20 CST 2006


On 11/13/06, Pringle, Ron <RPringle at aurora-il.org> wrote:
> Farmers Market - 11/13
> City Council Meeting - 11/15
> Farmers Market - 11/20
> Farmers Market - 11/27
>
> What I want to do:
>
> Farmers Market - 11/13, 11/20, 11/27
> City Council Meeting - 11/15

This is a classic problem. If your dataset is small, you may want to
just use separate queries. This goes against the hardwiring of us
programmers who want to optimize everything before there's even a
problem, but in the end it costs less.

If your dataset is larger, then basically you want to flatten out the
set, like you have in your "what I have" section, but you want to
*order it by event*. Then loop through thusly:

begin loop
   get next record
   if event has changed then
         print event name
         print date
   else
        print comma, space, date
   end if
end loop

-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list