sadly not, it still lists duplicate file_id records, ie
if a file_id has 2 version the query prints out both rather than only the record with the greatest version number :(
arghhhhhhh!
SQL error on peter's SQL, MySQL doesn't like a.version_number in having clause, I've tried all the aliases I can think of:
Here is a dump of the table with real data, it might help:
DROP TABLE IF EXISTS `version`;
CREATE TABLE `version` (
`id` bigint(20) NOT NULL auto_increment,
`file_id`...
very close..... I've tried it and it certainly works except... (you were waiting for that!)
it returns for every file_id the version number rather than just a result set of file_id and max version number.
In other words:
where file_id=5 and there are 3 versions of file_id=5 it returns a row...
Yes indeed
When I run my query I can get the correct max version number but it also returns the wrong filename (of that version number). It returns the version 1 filename of the correct file_id and not (in this example) the version 3 of the correct file_id.
so I would like this:
8 | 6...
Hi
Sorry it's hard to explain!
All the rows for package_id=11 are shown (there are many other rows with different package_id's)
What I want isthe max version number for each file_id.
So based on file_id (file_id represents a unique file) and also on version I need the max version for each...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.