0

I Have "user_chat" table name his 4 columns

"msg_id" Auto Increament
"chat_from_id"
"chat_to_id"
"chat_msgs"

  SELECT `chat_msgs` from `user_chat` where chat_from_id='2'AND chat_to_id='10' LIMIT 0,10 

Also I have used DESC using above queary but not worked

I want to fetch last 5 recent records from "chat_msgs" columns

Suggest me.

Thank you

3
Contributors
4
Replies
24
Views
3 Years
Discussion Span
Last Post by Jefferson_1
0

try to order the results by the msg_id descending

something like...
select chat_msgs from user_chat where chat_from_id='2' and chat_to_id='10' limit 0,10 order by msg_id desc

0

@Patrick: its not work i have checked.

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by msg_id desc' at line 1

Edited by ravi142: error show

0
SELECT `chat_msgs` from `user_chat` where chat_from_id='2'AND chat_to_id='10' Order by MSG_ID DESC LIMIT 0,5

Above code will show you the 5 most recent chat

Limit 0,10 will gave you the 10 recent chat

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.