mysql - How get MAX(id) for each username? -
i have mysql table:
how maximum id each username?
like above in image, desire rows username 'mostafa' or 'samsung' max id.
i testing lot of query, :
select max(id) , latitude, longitude 'users_geo' username = 'mostafa'
this returns record max id username mostafa.
also test query:
select id, latitude, longitude `users_geo` username = 'samsung' having max( id ) limit 0 , 30
this query return wrong result. query return row id=9
while max id user 'samsung' 21
.
use mysql
group by aggregate (group by) functions namely max
in case.
select username, max(id) users_geo group username;
Comments
Post a Comment