2
I would like to list the books in order of most borrowed, but there is no book that was borrowed so it shows none. I’d like you to show it in order but even if the book hasn’t been borrowed at all it has to be listed.
SELECT Livros.Nome, COUNT(Emprestimo.Livro_IDLivro) FROM Livros
INNER JOIN Emprestimo ON Livros.IDLivro = Emprestimo.Livro_IDLivro
ORDER BY COUNT(Emprestimo.Livro_IDLivro) ASC;
Jose, your problem is very simple. I suggest you read the post to understand the difference between the
INNER
and theLEFT
: http://answall.com/questions/6441/qual%C3%A9-a-difference%C3%A7a-entre-Inner-Join-e-outer-Join– Ismael