I have a table called Comments that stores messages between two users, and the table structure looks like this:
id | from_id | to_id | comment | date
I want to query the data to only display the latest message between the two parties.
I’ve seen it done before.
I am using MYSQL.
Let’s say the two users id numbers are
1and2.If you really wanted to be pedantic, you could add this to the where clause:
to prevent cases where they send a message to themselves showing up. This assumes it’s even possible for a user to send a message to them self in your system.