2 Select or 1 Join query ?
Posted
by xRobot
on Stack Overflow
See other posts from Stack Overflow
or by xRobot
Published on 2010-06-13T15:49:11Z
Indexed on
2010/06/13
15:52 UTC
Read the original article
Hit count: 226
I have 2 tables:
book ( id, title, age ) ----> 100 milions of rows
author ( id, book_id, name, born ) ----> 10 millions of rows
Now, supposing I have a generic id of a book. I need to print this page:
Title: mybook
authors: Tom, Graham, Luis, Clarke, George
So... what is the best way to do this ?
1) Simple join like this:
Select book.title, author.name
From book, author
WHERE ( author.book_id = book.id ) AND ( book.id = 342 )
2) For avoid the join, I could make 2 simple query:
Select title FROM book WHERE id = 342
Select name FROM author WHERE book_id = 342
What is the most efficient way ?
© Stack Overflow or respective owner