我有问题将下面的查询连接在一起,以便它工作效率更高。可以请某人告诉我如何连接这两个查询,以便它只有一个?如何连接两个表,以查看两个表中是否存在任何值
$rs_duplicate = mysql_query("select count(*) as total
from advertisers_account
where user_email='$user_email' ") or die(mysql_error());
list($total) = mysql_fetch_row($rs_duplicate);
}
$rs_duplicate_pub = mysql_query("select count(*) as total
from publishers_account
where user_email='$user_email' ") or die(mysql_error());
list($totalpub) = mysql_fetch_row($rs_duplicate_pub);
if ($totalpub || $total > 0)
{
echo "Not Available ";
} else {
echo "Available";
}
* PSA:* mysql_ *函数是[在PHP 5.5中弃用](http://php.net/manual/en/faq.databases.php#faq.databases.mysql.deprecated)。不建议您编写新的代码,因为这会阻止您将来升级。相反,请使用[MySQLi](http://php.net/manual/en/book.mysqli.php)或[PDO](http://php.net/manual/en/book.pdo.php)和[是一个更好的PHP开发人员](http://jason.pureconcepts.net/2012/08/better-php-developer/)。 –
我也不确定将结果集接收到'list($ total)'中。我相信你应该只使用'$ total'。 – alfasin