I have the following tables:
CATEGORY
id(int)
1000
1001
BOOK
id(int) category(int) rating(float)
3000 1000 5.0
3001 1000 4.8
3002 1000 3.0
3003 1000 4.9
3004 1001 4.9
3005 1001 3.0
What I want to do is to take 3 books with the highest rating from each category. After inspecting and completing the answer given in SQL JOIN RESTRICTION , I tried this query.
SELECT * FROM book, category WHERE book.category=category.id AND book.id IN (SELECT book.id FROM book ORDER BY rating LIMIT 3)
But it gives the following error:
The solution said that a minimum of MySQL 5.1 is required , and I run libmysql - 5.1.73 . What could be wrong?
source
share