我假设你原来查出N条数据的代码如下:(你自己替换成你的)
select * from tb order by col ;
现在你改成这样:
SET @row_number =0;
select *, @row_number := @row_number+1 AS row_number
from tb
order by col;
--看到了吧 用变量来产生一个序列
--如果你要查询特定值,可以这样
select row_number
from (
select *, @row_number := @row_number+1 AS row_number
from tb
order by col) k
where 字段名='你要的字段值';
我想到一个:
//前面不用说吧
mysql_query(select * table where file='velue')
while($row=mysql_fecth_array){
$i++;
}
echo $i //i就是你想要的结果,应该看的明吧。
SELECT COUNT(*) FROM table WHERE name = xxx
查询数据的ID ?