Carl Seghers wrote:

> An alternative would be to use PHP to do the SELECT of the maximum dates
> and INSERT them into a temporary table, and then INNER JOIN the two
> tables.   A more experienced MySQL guru might know better ways (I am
> also quite new to the matter myself).


Ok, here's an alternative without using PHP, only with SQL statements.

DROP TABLE IF EXISTS maxdates;
CREATE TABLE maxdates SELECT name,max(date) AS date FROM customers GROUP 
BY name;
SELECT customers.name,customers.date,code FROM customers INNER JOIN 
maxdates USING (name,date);
DROP TABLE maxdates;

Not sure as of which version this is valid.  As before it is on my 
system with MySQL 4.1.9.

Rgds,
Carl



The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to