Re: multiple tables and amounts
| From: | ma | Date: | Thu, 29 Jan 2004 15:40:19 +0000 |
| Subject: | Re: multiple tables and amounts | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-32697@lists.php.net to get a copy of this message | ||
hi!
thanks a lot for your answer. i also thought of dividing the problem into
several selects, but the application i'm working with (it's designed by a
friend of mine, which lets you easily generate XML out of an sql) only
accepts one single query..
do you know about any problems using CREATE TEMPORARY TABLE - eg. when there
are a lot of users accessing the page?
thx for your help again!
-mathew
# die welt ist schnell geworden...
> Von: "Hutchins, Richard" <Richard.Hutchins@Getingeusa.com>
> Antworten an: Richard.Hutchins@Getingeusa.com
> Datum: Thu, 29 Jan 2004 08:25:03 -0500
> An: "'grillen@abendstille.at'" <grillen@abendstille.at>
> Betreff: RE: [PHP-DB] multiple tables and amounts
>
> Matt,
>
> What about this (assuming MySQL):
>
> //$photoid is whatever photo you want the details for.
> $sql_a = "SELECT id FROM comments WHERE phid = '".$photoid."'";
> $sql_b = "SELECT id FROM ratings WHERE phid = '".$photoid."'";
>
> $result_a = mysql_query($sql_a) or
> die(mysql_error());
> $num_comments = mysql_num_rows($result_a);
>
> $result_b = mysql_query($sql_b) or
> die(mysql_error());
> $num_ratings = mysql_num_rows($result_b);
>
> echo "There were ".$num_comments." comments and ".$num_ratings." for
> that
> photo.";
>
> Since you're not doing anything really difficult with the queries, you
> probably won't see much of a speed hit by doing back-to-back queries like
> this. Besides, I think doing two straight queries like this is going to be
> faster than creating and deleting temporary tables. Just a guess.