Comparing tables using the join title with LIKE and CONCAT?

1

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,'%'))

But it did not work. the tables

    
asked by anonymous 06.05.2016 / 00:01

0 answers