php - Select DISTINCT rows of multiple columns in mysql -



php - Select DISTINCT rows of multiple columns in mysql -

i have table called sk_messages.it's construction following:

msg_id msg_from_user_id msg_to_user_id msg_text msg_date msg_status 1 12 14 hai... 23-12-2013 unread 2 12 14 .... ... unread 3 13 14 ... .. unread

my requirement want display messages current user status single message should displayed sender if sends multiple messages status unread.that is,from above context, single message of user having id 12, should displayed.i have tried next query,but doesnt work.

select distinct (msg_from_user_id), msg_text, msg_date sk_messages msg_to_user_id = '$user_id' , msg_status = 'unread' order msg_date $user_id id of login user

try group user id.

select msg_text, msg_date sk_messages msg_to_user_id = '$user_id' , msg_status = 'unread' grouping msg_from_user_id order msg_date

tested code latest message

'select * ( select * message user_id = 1 order created desc limit 1) msg grouping user_id '

php mysql sql distinct

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -