Willem Bogaerts wrote:
>>> And on the other hand, the join could cause some very large blob field
>>> to be transmitted for each row, whereas 3 queries would do this only
>>> once. So I guess the best answer is a bit situation-dependent.
>>>
>>> Regards,
>> And why would that be, Willem?
>
> If you have, for instance a book table and an author table, and a book
> is written by more than one author, you could write:
>
> SELECT book.content, author.name FROM book NATURAL JOIN author WHERE
> book.id=5;
>
Why would it? You asked for book.id = 5. It will return one row
(assuming book.id is a unique field).
> This would return the entire content of the book for each author
> (far-fetched example, I know). Whereas:
>
> SELECT content, @author_id:=authorId FROM book WHERE id=5;
> SELECT author.name FROM author WHERE id=@author_id;
>
> Would pass the content only once. So less data would go over the line,
> but effectively the exact amount of data is given, because the duplicate
> fields are removed.
>
> Or am I wrong in this?
>
> Regards,
You are incorrect. In fact, the second one will require two calls to
the database to retrieve the same information the first one did in one call.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================