How do I use my join tables MySQL? -
i have 3 tables in mysql database,
author
book
author_has_book.
the author has 2 columns
idauthor
name
book has 2 columns
idbook
name
author_has_book has 2 columns
foreign keys of author , book book_idbook
author_idauthor.
i have inserted author , book both tables , have entered keys join table.
now how use join table books author, or authors book? accomplished joins?
edit: suggested duplicate not same question.
it records
select author.* author author inner join author_has_book authorhasbook on author.idauthor = authorhasbook.author_idauthor inner join book book on authorhasbook.book_idbook = book.idbook and if wish select specific author, need mention in clause, see example below:
select author.* author author inner join author_has_book authorhasbook on author.idauthor = authorhasbook.author_idauthor inner join book book on authorhasbook.book_idbook = book.idbook author.idauthor = 'your author id'
Comments
Post a Comment