SELECT id, name FROM `products`
WHERE (`category_id`='КН3')
AND EXISTS(SELECT * FROM product_book WHERE product_book.product_id = products.id
AND product_book.book_name = 'book_language'
AND (SELECT name FROM book_language WHERE id = product_book.book_id) IN('Русский'))
AND EXISTS(SELECT * FROM product_book WHERE product_book.product_id = products.id
AND product_book.book_name = 'book_binding'
AND (SELECT name FROM book_binding WHERE id = product_book.book_id) IN('Твердый'))
if(!empty($this->author)){
$sql = new Expression("(SELECT name FROM book_authors WHERE id = product_book.book_id)");
$row = (new Query())
->from('product_book')
->where('product_book.product_id=products.id')
->andWhere(['product_book.book_name' => 'book_authors'])
->andFilterWhere(['in', $sql, $this->author]);
$query->andFilterWhere(['exists', $row]);
}