SELECT * FROM tbUsuario user JOIN tbAmizade am, tbGenMus gen WHERE NOT
((am.fkUsuarioSend = user.usId AND am.fkUsuarioReceive = {$_SESSION['usuario']['usId']})
OR (am.fkUsuarioSend = {$_SESSION['usuario']['usId']} AND am.fkUsuarioReceive = user.UsId))
AND NOT user.usId = {$_SESSION['usuario']['usId']} AND gen.idGenMus = user.fkGenMus;
I created this query and it worked for a moment, but when the user sent more than one request, the query began to duplicate the results and put the ones that should not appear.