Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL erhält die neuesten Konversationsnachrichten

Versuchen Sie dies

SELECT * FROM
messageTable
WHERE from_id='abc123'
AND `time` = ( SELECT MAX(`time`) FROM messageTable WHERE from_id='abc123' )

UNION ALL

SELECT * FROM
messageTable
WHERE to_id='abc123'
AND `time` = ( SELECT MAX(`time`) FROM messageTable WHERE to_id='abc123' )