Re: How to optimize this MySQL command?

From: Date: Wed, 04 Jun 2003 13:44:52 +0000
Subject: Re: How to optimize this MySQL command?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-150157@lists.php.net to get a copy of this message
So, how about this? $resultb = mysql_query("SELECT id,title,mid,lastedit,hit,reply,lock FROM bt_message where ch='$ch' ORDER BY top,lastedit DESC LIMIT $limit,30",$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); mysql_free_result($result2b); .......... } -- "James Lobley" <james@westcoast.co.uk> ???????:6DD748110EA1D411AD1200A0C996FDFA013CE66F@host16.westcoast.co.uk... > I'd guess at: > > $resultb = mysql_query("SELECT bt_member.nick FROM bt_member, bt_message > WHERE bt_member.id=bt_message.mid AND bt_message.ch='$ch'", $db); > $result2 = mysql_fetch_array($resultb); > ......... > > > -----Original Message----- > From: Erick [mailto:webmaster@pczonehk.com] > Sent: 04 June 2003 13:12 > To: php-general@lists.php.net > 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 > > > This email is only intended for the person(s) to whom it is addressed and > may contain confidential information. Unless stated to the contrary, any > opinions or comments are personal to the writer and do not represent the > official view of the company. If you have received this e-mail in error, > please notify us immediately by reply e-mail and then delete this message > from your system. Please do not copy it or use if for any purposes, or > disclose its contents to any other person. > > We make every effort to keep our network free from viruses. You should > independently check this e-mail and any attachments for viruses, as we > can take no responsibility for any computer viruses that might be > transferred by way of this e-mail. > >

« previous php.general (#150157) next »