The table structure is as follows:
/*sqlyog v10.2 MySQL-5.5.39 **********************************************************************//*!40101 SET NAMES UTF8*/;Create Table' seal ' (' ID ')varchar( the), ' Update_user 'varchar( the), ' Update_time 'datetime, ' Seal_name 'varchar( Max), ' remark 'varchar( -), ' is_enable 'int(1), ' seal_image ' blob, ' seal_version 'int( One), ' Is_del 'int(1)); Insert into' Seal ' (' id ', ' update_user ', ' update_time ', ' seal_name ', ' remark ', ' is_enable ', ' seal_image ', ' seal_version ', ' Is_del ')Values('91B2B13C47AA4CF7B5FAF9093C899CFC','820e2deb8efe11e4b4a2bcaec5330601','2015-11-26 15:53:59','1','22222','1','??,'1','1'insert INTO ' seal ' (' id ', ' update_user ', ' update_time ', ' seal_name ', ' remark ', ' is_enable ', ' seal_image ', ' Seal_ Version ', ' Is_del ') VALUES ('91b2b13c47aa4cf7b5faf9093c899cfc','820e2deb8efe11e4b4a2bcaec5330601',' -- One- - the: Wu: the','1','1111','1','塒 ng\r\n\z\n','2','1');
The corresponding MySQL is as follows:
The demand now is: because the table uses the Federated primary key, Id+seal_version, so the ID may be the same,
Requirements: To find the same data as the ID, seal_version the largest data
select * seal SL left join ( select id,max (seal_version) as seal_version from seal group by ID) temp on sl.id= temp . ID and sl.seal_version= temp . Version
SQL, Federated primary Key, group by ID to find a collection of the maximum version number