Jump to content

select max date of column where with multiple uuid's


Fog Juice

Recommended Posts

Hello,

 

What I am trying to do is select the latest version of each uuid. Latest is determined by the unix time stamp in the date column.

 

Below is the table with data, could someone give me a hint on how to do this? This probably seems easy but sometimes the easiest things are overlooked.

 

 

Thanks!

 

CREATE TABLE IF NOT EXISTS `phpfreakstableexample` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `date` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `note` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=225 ;]


INSERT INTO `phpfreakstableexample` (`id`, `uuid`, `date`, `note`) VALUES
(1, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223150', 'test data for phpfreaks'),
(2, 'd6e52102-dfa9-c570-7550-fe92d5517329', '1245223987', 'test data for phpfreaks'),
(3, 'c4601d4c-d55e-16b3-11ff-85abba78a19a', '1245223988', 'test data for phpfreaks'),
(4, 'c4601d4c-d55e-16b3-11ff-85abba78a19a', '1245223989', 'test data for phpfreaks'),
(5, 'c4601d4c-d55e-16b3-11ff-85abba78a19a', '1245223990', 'test data for phpfreaks'),
(6, 'd6e52102-dfa9-c570-7550-fe92d5517329', '1245223991', 'test data for phpfreaks'),
(7, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223192', 'test data for phpfreaks'),
(8, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223193', 'test data for phpfreaks'),
(9, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223194', 'test data for phpfreaks'),

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.