<?php
$con = mysql_connect('localhost', 'root', 'pass');
if(!$con){
echo "Error connection";
}
$select_db = mysql_select_db('mydatabase', $con);
if(!$select_db){
echo "Error to select database";
}
mysql_set_charset("utf8", $con);
$result = mysql_query("select count(1) FROM Credit WHERE CreditStatusID=6");
$row = mysql_fetch_array($result);
$total = $row[0]-1;
echo "<font size='6px' color='#000000'>Total: </font><font size='6px' color='#FF0000'><b>" . $total . "</b></font>";
mysql_close($con);
?>
我需要获取一些其他信息,例如WHERE CreditStatusID=6 AND CreditStatus=7,8,9,..
,但它不起作用。你能解释一下我怎么能以另一种方式做到这一点?
答案 0 :(得分:0)
尝试:
select count(1) FROM Credit WHERE CreditStatusID=6 and CreditStatus in (7,8,9)
答案 1 :(得分:0)
WHERE子句应如下所示:
...WHERE CreditStatusID=6 AND CreditStatus IN (7, 8 ,9);
代替数组&#34;(7,8,9)&#34;你也可以使用子选择..