Hi,
You can try some variation:
SELECT
book_id
FROM
bookgenres, genre_children
WHERE
bookgenres.genre_id = genre_children.genre_child_id AND
genre_children.genre_id = 1
GROUP BY book_id
LIMIT 10
The next works if the 'genre_child_id' is UNIQUE on the 'genre_children'
table.
SELECT
book_id
FROM
bookgenres
WHERE
bookgenres.genre_id = (SELECT genre_child_id FROM genre_children
WHERE genre_id = 1)
GROUP BY book_id
LIMIT 10
You may need some index. Try these with EXPLAIN!
CREATE INDEX bookgenres_genre_id_book_id ON bookgenres(genre_id,
book_id); or
CREATE INDEX bookgenres_book_id_genre_id ON bookgenres(book_id,
genre_id);
CREATE INDEX genre_children_genre_id ON genre_children(genre_id);
Regards, Antal Attila