What you're asking is considered a UNION. I'm not sure which database you're using, so I can't tell if it supports UNIONs or not. If you're using MySQL, UNIONs are supported in version 4.0-alpha.
Another approach is storing the results of both queries in single array and then pulling it from there when you need to work with it. Then again... you don't seem to be sorting the results, so you could just as easily start the table, run the db query, dump the results, run another query and dump the results, and then close the table. I don't know if what I just said makes sense, so here's a psuedo example: <table> <?php $sql = "query#1"; $Results = mysql_query($sql, $DBLink); while ($Row = mysql_fetch_array($Results) ) { print "<tr>"; print "<td>".$Row[0]."</td>"; print "<td>".$Row[1]."</td>"; print "<td>".$Row[2]."</td>"; print "</tr>"; } $sql = "query#1"; $Results = mysql_query($sql, $DBLink); while ($Row = mysql_fetch_array($Results) ) { print "<tr>"; print "<td>".$Row[0]."</td>"; print "<td>".$Row[1]."</td>"; print "<td>".$Row[2]."</td>"; print "</tr>"; } ?> </table> -----Original Message----- From: Danny Kruitbosch [mailto:[EMAIL PROTECTED]] Sent: Monday, June 10, 2002 1:09 PM To: [EMAIL PROTECTED] Subject: [PHP] Compare 2 resultsets of db-query Hi, I've two queries on the same table. They have the following structure: Query1: SELECT FIELD1, COUNT(FIELD2) AS TOTAL from TABLE GROUP BY FIELD1 Query2: SELECT FIELD1, COUNT(FIELD2) AS SUB from TABLE WHERE FIELD2=1 GROUP BY FIELD1 Now I want to print a table that prints the values of FIELD1, TOTAL and SUB. Query 1 returns more rows as query 2. Field1 is the same in both queries so I should be able to 'link' the results of both queries together. How do I do this?? Thanks! Danny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php **************************************************************************** This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php