$query1= mysql_query("select r.nid from ....");
$query2= mysql_query("select t.nid from....");
这两个查询都返回一个nid。如何比较2返回的nid是相等的..我只是一个初学者。
答案 0 :(得分:1)
$row1 = mysql_fetch_row($query1);
$row2 = mysql_fetch_row($query2);
if($row1[0] == $row2[0])
{
//something
}
答案 1 :(得分:1)
你可以在纯sql中完成它。像这样:
select
r.nid
from
....
WHERE EXISTS
(
select
NULL
from
....
WHERE
t.nid = r.nid
)
答案 2 :(得分:1)
如果你确定查询确实返回了一个id,你可以加快检查:
$query1 = mysql_query("select r.nid from ....");
$query2 = mysql_query("select t.nid from ....");
if(mysql_fetch_field($query1, 0) === mysql_fetch_field($query2, 0))
{
//do something
}