Hi,
I have tree tables
- books
- bookmarks
- users
where there is a n to m relation from books to users trough bookmarks.
Im looking for a query, where I get all the books of a certain user including the bookmarks. If no bookmarks are there, there should be a null included...
my sql statement looks like:
SELECT * FROM `books`
LEFT OUTER JOIN `bookmarks `
ON bookmarks.book_id = books.id
AND bookmarks.user_id = ?
In rails I only know the :include statement, but how can I add the second bookmarks.user_id = ? statement in the ON section of this query? if I put it in the :conditions part, no null results would get returned!
Thanks! Markus