php - Mysql group by fetch last row -
select * conversation_1 left join conversation_2 on conversation_1.c_id = conversation_2.c_id left join user on conversation_2.user_id = user.user_id left join message on conversation_1.c_id = message.c_id conversation_1.user_id=1 group message.c_id conversation_1 conversation_2 c_id user_id c_id user_id 1 1 1 2 2 1 2 3 3 2
i have message db build in mysql
i make 4 tables user, conversation_1, conversation_2, message
when user try open message box, fetch out conversations(conversation_1)
than join user conversation_2 , use conversation_2 find out user
than join message.
c_id user_id user_name message 1 2 alex hi user_1, user_2 2 3 john hi user_3, user_2 don't talk me
it works fine, want display message
last row group by
currently display 1st row in group.
ps.conversation_1.c_id auto increment , c_id insert conversation_2 has join conversation
select * (select * conversation_1 left join conversation_2 on conversation_1.c_id = conversation_2.c_id left join user on conversation_2.user_id = user.user_id left join message on conversation_1.c_id = message.c_id conversation_1.user_id=1 order conversation_1.c_id desc) finaldata group message.c_id
Comments
Post a Comment