This is my code:
SELECT b.nameBook, a.firstName, a.lastName FROM books b
INNER JOIN books_author ba ON b.idBook = ba.BooksId
INNER JOIN author a ON a.idAuthor = ba.AuthorId
ORDER BY b.nameBook;
I don't want to repeat the books name (in this case, "Fisica 11"). I want it like this. How can I do it? Sorry if this is a dumb question, i'm a beginner.
Also, I wanted to ask if there is any difference between the code above and the one below and which one is better to use:
SELECT nameBook, lastName, firstName
FROM books b, author a, books_author ba
WHERE ba.AuthorId = a.idAuthor
AND ba.BooksId = b.idBook
Both of them give the same result.
I tried GROUP BY but this is what happens.
I could easily fix this by using php but I want to use SQL. Thank you.