[EMAIL PROTECTED] wrote:

Hi,
I am running MySQL 4.0.10 gamma.
I have records with data:
id title  version
1    a         1
2    a         2
3    b         1
4    b         2

How do I select all the records with highest version for each title?
(The records with id 2 and 4)
I've been thinking about combinating GROUP BY and max(), but I cant get it to work...
"SELECT id, title, max(version) FROM table GROUP BY title;" returns
1 a 2
3 b 2


Thanks for any help /Ola


Because this is not proper SQL. 'id' is in neither the MAX aggragate function nor the GROUP BY.
You told the server you want only 1 line per title with GROUP BY title, but the server has no way of
knowing which line you want.
MySQL allows this syntax where other servers don't, because sometimes it is useful. You have to be careful though.



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to