The way I think I'd approach it is to use an outer join where table a is joined
to a subquery where the subquery returns only the
max timestamp from table b.
> -----Original Message-----
> From: Graham Cossey [mailto:[EMAIL PROTECTED]
> Sent: Thu, March 06, 2008 5:17 PM
> To: J. Hill; firstname.lastname@example.org
> Subject: Re: [PHP-DB] Help with JOIN query
> On Thu, Mar 6, 2008 at 9:54 PM, J. Hill <[EMAIL PROTECTED]> wrote:
> > I may be a little confused: the desire is to return all the
> rows from
> > TableA that match the record_id of a row in TableB that has the MAX
> > timestamp?
> > If so, why not something like:
> > SELECT * FROM TableA a, TableB b WHERE a.record_id=b.record_id &&
> > timestamp=(SELECT MAX(timestamp) FROM TableB) ORDER BY action;
> > I'm guessing I'm confused, that it's something more
> complicated you're
> > looking for.
> Thanks Krister and all for your help thus far.
> Jeff, I'm after all rows from TableA then the latest action from
> TableB for each selected record in TableA.
> I'm starting to think maybe I should build an array of results using 2
> queries then sort the array using PHP functionality, but I'd rather do
> it in MySQL if it's possible.
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php