How does the sql statement query the list of private messages?

my need is to be able to make a list of private messages and take the last private message record. For example, the structure of the data table:
id pid from_userid to_userid content time
10 a b hi 01
21 b a hello 02
3 1 a b hihi 04
40 a c test 09
54 c a test1 11
the list that needs to be obtained is
a b hihi 04
c a test1 11
how to write this sql sentence?

Mar.04,2021

do you want to: the last record of others trusting my and my private trust respectively?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e47b36-44495.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e47b36-44495.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?