Re: How to optimize this MySQL command?
| From: | Sunil Samuel | Date: | Wed, 04 Jun 2003 15:09:23 +0000 |
| Subject: | Re: How to optimize this MySQL command? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-150190@lists.php.net to get a copy of this message | ||
This is actually more an sql questions. ;-) Take a look at Joins in sql. Should be something like the following:
SELECT mesg.id, mesg.mid, memb.nick
FROM bt_message mesg, bt_member memb
WHERE mesg.ch='$ch' AND memb.id=mesg.mid
Erick wrote:
$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?