'How to get all messages between sender id and receiver id on mysql?

Im making a chat application with node js and mysql and i need to get all the data between sender id and receiver id but im stuck in that .

Need to get all the communications between these 2 id



Solution 1:[1]

SELECT * FROM messages WHERE (sender = '" + request.body.sender + "' AND receiver = '" + request.body.receiver + "') OR (sender = '" + request.body.receiver + "' AND receiver = '" + request.body.sender + "')"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bleron Mexhuani