mysql - Group query doesn't value corresponding values -
i have query works alright in grouping highest order. i've realized able pick ids
alright values of vmsg
field not corresponding of id
.
for example id of 28
corresponds vsmg
'hello' after run query id of 28
picks different value .
this how looks backend
and script
select max(id) id, vmsg, sender_id, fname, lname, profile_pix, profile.profile_id chats left join profile on chats.sender_id = profile.profile_id reciever_id = 1 group (sender_id)
i :
i max ids
vmsg
values don't correspond.
if need data corresponding max(id)
, can modify query :
select c.id, c.vmsg, c.sender_id, c.fname, c.lname, p.profile_pix, p.profile_id chats c left join profile p on c.sender_id = p.profile_id c.reciever_id = 1 , c.id in ( select max(c.id) id chats c group c.sender_id )
this fetch data corresponding max(id)
.
Comments
Post a Comment