I need to retrieve all possible combinations from two columns of a database. I need to find all the rows that contain two UserID in the first or second column and reverse.
I have tried several times to create this request, even with more sql, but it doesn't work for me.
$sql = "SELECT * FROM chat WHERE UserID1='$userchatid' AND UserID2='$userid' OR UserID1='$userid' AND UserID2='$userchatid' ORDER BY id DESC";
I need the script to retrieve the people who write to you in a chat and make them stand out at the top