【发布时间】:2013-04-30 03:02:23
【问题描述】:
我在数据库中有两个表,我想使用 ist 表的结果并将其与第二个表进行比较,例如:
// we connect to example.com and port 3307
mysql_connect("localhost", "root", "pass123") or die(mysql_error());
mysql_select_db("PhGateway") or die(mysql_error());
$result = mysql_query("select mtMsgId from SMS where SMS.`result` = '0' ");
while($row = mysql_fetch_array($result))
{
$mtMsgid=$row['mtMsgId'];
}
我想将$mtMsgid的结果与另一个表进行比较然后显示
另一个表名是 DN,有两个字段 mtMsgId 和 msgStatus
喜欢:
select * from DN where mtMsgId = 'the whole above result'
【问题讨论】:
-
1.使 $mtMsgid 成为一个数组。 2.使用
IN():'select * from DN where mtMsgId IN('.implode(',', $mtMsgid).')'3.或者使用JOIN