I have a db named library. There are authors, books, books_genres, genres, history
I have more 5 books in genre with name "Horror", 3 books in genre with name "comedy" and 2 books in genre with name "Romance"
I have a check boxes with all my genres and when i selected them i want the results to be grouped by genre with most records on in on TOP. Here is some code:
"SELECT title, price, genre_id, name
FROM books
INNER JOIN books_genres ON books.id = books_genres.book_id
INNER JOIN genres ON books_genres.genre_id = genres.id
WHERE genre_id IN ({$ids})";
this return to me all the books but without the order i want.
ids are string with genre ids like 1,2,3,4