Wouldn't it be easier to "SELECT * from bt_member WHERE ch='$ch' && id='$result[mid]',$db); //I'm not sure of the exact syntax there since I'm a newbie, but wouldn't it be easier to do that and then do a pulling of the fields that you want? //ie... while ($result = mysql_fetch_object($resultb)){ print "<TR>\n"; print "<td width=90 valign=\"top\">$row->id</td>\n"; print "<td width=90 valign=\"top\">$row->mid</td>\n"; print "<td valign=\"top\">$row->nick</td>\n"; print "</tr>\n";
} print "</Table>\n"; print "</Center>\n"; I took this from an example that I have now for something similar, it uses fetch_object, you could still use fetch_array, and just use a $row['id'] or something too. Good luck with this, maybe someone who knows correct syntax could clean this up a bit. I guess my opinion is that it slows the processor down having to pull only certain fields from the database compared to just pulling all of them from a certain table. Most tables shouldn't be that big, if they are you should be using primary keys and making other tables that is the point of a relational database. ;) You can always join tables in the end. (ramblin again!!, sigh) Best of luck, David -----Original Message----- From: Erick [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 7:12 AM To: [EMAIL PROTECTED] Subject: [PHP] How to optimize this MySQL command? $resultb = mysql_query("SELECT id,mid FROM bt_message where ch='$ch' ",$db); while ($result = mysql_fetch_array($resultb)) { $result2b = mysql_query("SELECT nick FROM bt_member where id ='$result[mid]' ",$db); $result2 = mysql_fetch_array($result2b); ......... } Can combine together? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php