Re: SQL Join query
| From: | Lenar Lõhmus | Date: | Sun, 08 Aug 2004 08:37:47 +0000 |
| Subject: | Re: SQL Join query | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193124@lists.php.net to get a copy of this message | ||
Mattias Thorslund wrote:
> Though, (regardless of SQL database platform) in a case like this, it
> MAY be both more straightforward and efficient to use two separate
> queries for the pictures and comments, given the one-to-many cardinality
> between them. The above statement causes redundant data to be returned
> - it duplicates the pics record for each new comment. If there are many
> large columns in the pics table and many comments to each record there's
> a lot of redundant data in a query like that.
No, I think you are wrong. There was GROUP BY pics.id so it won't return
duplicate data. And probable overhead is eliminated too I think - DBserver
will optimize and will join data from pic_comments only once for each
unique pics.id.
Lenar