You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and users_books.class_id=classes.id group by classes.id limit 5' at line 1
select classes.id,class_name from classes,users_books where users_books.book_id= and users_books.class_id=classes.id group by classes.id limit 5