mysql - Get latest rows from my sql database -


i have table there in rows there column called version. have 2 same entries 1 column abc(unique) in same rows. have 2 rows follows

id|name|version|unique_id ------------------------- 1 |abc |1      | 23 2 |abc1|2      |23 3 |xyz |1      |21 4 |tre |1      |20 

i want result as

id|name|version|unique_id ------------------------- 2 |abc1|2      |23 3 |xyz |1      |21 4 |tre |1      |20 

i have tried grouping unique_id, result follows

id|name|version|unique_id ------------------------- 1 |abc |1      | 23 3 |xyz |1      |21 4 |tre |1      |20 

following query using

select *  test group unique_id order version desc; 

i want latest(top order desc) of each each rows. please help. how can achieve that.

how like

insert tbllogs              (logorigin,               logaction,               loguser,               logdate,               logoutcome)  values      (:origin,               :action,               :user,               :dt,               :outcome)  

use sub select determine id , max version number, join original table retrieve other values.

sql fiddle demo


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -