Re: SQL help?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Skip Evans wrote:
> Hey all,
> 
> I have a SQL requirement I'm not quite sure how to compose.
> 
> I have two tables, shows, and shows_dates. It's a one to many
> relationship where there is a single entry in shows and multiple entries
> in shows_dates that list each date and time for a play production for a
> run of entries in shows, like
> 
> I need a query that will read each record in shows, but I only want the
> first record from shows_dates, the first one sorted by date, so I can
> display all shows in order of their opening date.
> 
> Not sure how to grab just the first record from shows_dates though.
> 
> Hint, anyone?
> 
> Thanks,
> Skip
> 


Join the two tables like you normally would do and aggregate the opening
date column with your dbms-specific max function and finally group the
result by a distinct value from shows.

It would have bee easier if you stated which rdbms you use ...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux