MySQL Forums
Forum List  »  PHP

Re: query within query
Posted by: David White
Date: April 07, 2006 06:15PM

This gives me the right records, in order, one of each required, but shows the oldest statdate data rather than the most recent...

- produces similar results with or without the left join.

select
s.site_id,
s.site_name,
DATE_FORMAT(s1.date,'%d %M %Y') as statdate,

from
cp_SITEs as s

INNER JOIN cp_STATs s1 using ( site_id )

left join cp_STATs as s2 on s.site_id=s2.site_id and s1.date > s2.date

where
s.parent_id= 1

group by
s1.site_id

order by
s1.site_id asc, s1.date desc

Options: ReplyQuote


Subject
Written By
Posted
April 06, 2006 03:06PM
April 06, 2006 04:28PM
April 06, 2006 05:47PM
April 06, 2006 05:58PM
April 06, 2006 09:36PM
April 07, 2006 04:48PM
Re: query within query
April 07, 2006 06:15PM
April 07, 2006 09:23PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.