Solution: How to select the last 25 entries from mysql?

Development | Databases
Description
I have the last 25 records but they go from the last record and up(I don’t know if I put it clearly), but the sorting should be the other way around, i.e.by the date the message was written, i.e.the 25th record(below the table ) until the end! but I do not understand how to do it.
I do this:
SELECT1
    users.login,
    user_date.name,
    user_date.lastname,
    user_date.company_name,
    user_date.company_link,
    user_date.user_img,
    message_in_the_chat.id,
    message_in_the_chat.from_user_id,
    message_in_the_chat.to_user_id,
    message_in_the_chat.message,
    message_in_the_chat.read_status,
    DATE_FORMAT(message_in_the_chat.write_data,"% d.% M.% Y% H:% i") as msg_data
FROM message_in_the_chat
LEFT JOIN users ON users.id=message_in_the_chat.from_user_id
LEFT JOIN user_date ON users.id=user_date.user_id
WHERE(message_in_the_chat.from_user_id=1 AND message_in_the_chat.to_user_id=30)
OR(message_in_the_chat.to_user_id=1 AND message_in_the_chat.from_user_id=30)
ORDER BY `write_data` DESC LIMIT 25
Attachments
No attachments
Solutions
Description
SELECTSELECT * FROM(
   SELECT
       message_in_the_chat.write_data write_data,
       users.login,
......
ORDER BY `write_data` DESC LIMIT 25
) sub
ORDER BY sub.write_data ASC

on December 13th, 2019 (10:36 pm)
All coments
This solution has not been commented yet.
You must sign in to comment!! LOGIN
We use cookies to give you the best possible experience on our site. By continuing to use the site you agree to our use of cookies. Find out more Accept