"Sandeep Hundal" <[EMAIL PROTECTED]> wrote:
> Now what I want to do is have another query which asks the second
> table the number of comments per each section id, for that section,
> (and I think QUERY2 does this fine). But I need the answers to
> integrate with the information pulled from first query. How can I
> intergrate the results from 2 queries into one basically!

> $query1 = " SELECT entry FROM diary WHERE month='$month' ORDER BY id
> desc";
> $result1 = mysql_query($query1);
>
> $query2 = "SELECT count(*) AS replies FROM sexsurvey_boys WHERE
> section='diary' GROUP BY sectionid ORDER BY sectionid desc";
> $result2 = mysql_query($query2);

There's no common fields b/w the two queries so it's not clear how you want
to merge the two queries.  If you wanted all results from one table and
matching results from a second table based on a common field in both tables
I'd suggest a LEFT JOIN (plenty of documentation on mysql.com and rest of
internet).  Looks like this probably won't help in your case so you might
want to look at temporary tables, which will allow you to save the results
from one or both queries into a table and then run a query using the
temporary tables.  Or you may be able to organize your PHP code to run the
second query after each row of the first query is returned and integrate the
results within PHP, but you could end up running a ton of queries that way.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to