已经说得很清楚了。用in。$sql="SELECT writer,count(*) as total FROM archives where ismake='0' and writer in ('1中队','2中队','3中队','4中队') group by writer order by total"
$query="SELECT * FROM archives WHERE (ismake='0' AND (writer='01' OR writer1='02' OR writer2='03' OR writer3='04')) ORDER BY id";
<?php $link=mysql_pconnect("localhost","root","xx") or die("Could not connect"); mysql_select_db("dbname") or die("Could not select database"); $query="SELECT writer,count(*) as total FROM archives where ismake='0' and writer in ('1中队','2中队','3中队','4中队') group by writer order by total desc"; $result=mysql_query($query) or die("Query failed"); $i=0; echo "名次 名称 记录数<br>"; while($row=mysql_fetch_array($result)) { $i=$i+1; echo $i." ".$rows['writer']." ".$rows['totol']."<br>"; } mysql_free_result($result); ?>
谢谢各位帮忙
$link=mysql_pconnect("localhost","root","xx") or die("Could not connect");
mysql_select_db("dbname") or die("Could not select database");
$query="SELECT writer,count(*) as total FROM archives where ismake='0' and writer in ('1中队','2中队','3中队','4中队') group by writer order by total desc";
$result=mysql_query($query) or die("Query failed");
$i=0;
echo "名次 名称 记录数<br>";
while($row=mysql_fetch_array($result))
{
$i=$i+1;
echo $i." ".$rows['writer']." ".$rows['totol']."<br>";
}
mysql_free_result($result); ?>