Hi I am having trouble with a query to return only one instance of a name in a table.
For instance: id name town date 1 jack town1 2002-12-12 2 john town2 2002-12-13 3 jack town4 2002-12-21 4 jack town5 2002-12-30 5 john town2 2002-12-15 I want to have a query that will return this: id name town date 4 jack town5 2002-12-30 5 john town2 2002-12-15 So, I want only the last entry based on the name. I tried select MAX(id), name from table group by name select distinct name from table group by name But both sometimes fail. Note: I am using a sample table here, I suspect that in my table with the actual data, that there might be spaces before or after the names, so I might need to clean them up from the table ( any quick way of doing this?) as it seems to be the only logical explanation for the queries to return multiple instances. Also, the rows are not 100% unique wrt the other fields, so that might be why distinct won't work? Any ideas? --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php