Answer the question
In order to leave comments, you need to log in
How to modify SQL query with renaming of fields in tables joined via JOIN?
Removed books from tables for quick understanding -
books (id, name, author_id, genre_id)
authors - authors (id, name)
genres - genres (id_name)
query
SELECT * FROM `books`
JOIN `authors` ON (`books`.`author_id` = `authors`.`id`)
JOIN `genres` ON (`books`.`genre_id` = `genres`.`id`)
Answer the question
In order to leave comments, you need to log in
SELECT books.*, authors.name as aName, genres.name. as gName FROM `books`
JOIN `authors` ON (`books`.`author_id` = `authors`.`id`)
JOIN `genres` ON (`books`.`genre_id` = `genres`.`id`)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question