Question: I have a `books` , `users` and a `books_users` table.

Now, i want to get a book that is managed by me (user\_id = 3) and other user(user\_id = 18):

```
SELECT *
FROM books as Book
LEFT JOIN books_users as BookUser
    ON BookUser.book_id = Book.id
WHERE
    Book.user_count = 2 AND
    BookUser.user_id = 3 AND
    BookUser.user_id = 18

```

Problem:
as the left join splits the result of books in rows, it doesn't give a row with the two users...

Answer: 
I believe you want to join to the BookUser table twice to get both conditions and use DISTINCT to get the book once:

```
SELECT DISTINCT Book.*
FROM books as Book
LEFT JOIN books_users as BookUser1
    ON BookUser.book_id = Book.id
LEFT JOIN books_users as BookUser2
    ON BookUser.book_id = Book.id
WHERE
    Book.user_count = 2 AND
    BookUser1.user_id = 3 AND
    BookUser2.user_id = 18

```
```
SELECT *
  FROM books as B
 INNER JOIN books_users as BU1
    ON BU1.book_id = B.id
 INNER JOIN books_users as BU2
    ON BU2.book_id = B.id
 WHERE B.user_count = 2
   AND BU1.user_id = 3
   AND BU2.user_id = 18

```