I am creating a book exchange page, I made two tables of wishes and mine. until the part of the user's desire logged in to find the other books I managed to do, but I would like the other users to have the desire of the user's books logged. type: I have a book A and wish a B and another user to have B and wish an A, and only appear results with these conditions. The field of desire can be title, author and gender. My select I have done so far:
SELECT b.meu,b.autor, b.genero,b.userid, b.foto
FROM desejos AS a
INNER JOIN meus AS b ON
(CONCAT('%', a.desejo,'%') LIKE CONCAT('%', b.meu,'%')or
CONCAT('%', a.desejo,'%') LIKE CONCAT('%', b.genero,'%')or
CONCAT('%', a.desejo,'%') LIKE CONCAT('%', b.autor,'%'))
WHERE
a.userid = $_SESSION[id]
AND
b.userid != $_SESSION[id]
tentei colocar "and
CONCAT('%', b.meu,'%') LIKE (CONCAT('%', a.desejo,'%') or
CONCAT('%', b.genero,'%') LIKE CONCAT('%', a.desejo,'%')or
CONCAT('%', b.autor,'%') LIKE CONCAT('%', a.desejo,'%'))