请问如何统计记录条数?在线等候?

xhping801216 2002-05-31 04:15:32
我是一位初学者,我用的是mysql数据库,
我现在想统计某一表中满足条件的记录的条数,不知如何写,请各位帮忙。
谢谢!!!
...全文
86 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
_Shakespeare 2002-06-06
  • 打赏
  • 举报
回复
没什么意思
这样程序的移植性更好一点吧
dgj 2002-06-06
  • 打赏
  • 举报
回复
先学学PHP再到这里来问问题吧
redv 2002-06-06
  • 打赏
  • 举报
回复
请问在表的名称(table)前加$是什么意思?

$table是变量。
seebi 2002-06-01
  • 打赏
  • 举报
回复
select count(*) from tablename where 条件
skimeister 2002-06-01
  • 打赏
  • 举报
回复
$query="select count(*) as TOTAL from person where sex='人妖'";
$result=mysql_query($query);
$temp=mysql_fetch_array($result);
echo $temp['TOTAL']; //输出查询结果(记录数)
~~~~~~~~~~~~~~~~~~~~~~
xhping801216 2002-06-01
  • 打赏
  • 举报
回复
请问在表的名称(table)前加$是什么意思?
dongfangran 2002-05-31
  • 打赏
  • 举报
回复
给你一个麻烦的例子:
<?
//
$query="select * from $table where .....";
$result=@mysql_query($query);
$num=@mysql_num_rows($result);
.....
?>
$num 即为满足条件的纪录。
xhping801216 2002-05-31
  • 打赏
  • 举报
回复
sql语句我很清楚,如何执行这条语句,怎么引用执行后的结果。
skimeister 2002-05-31
  • 打赏
  • 举报
回复
sorry

is "from"
not "form"
skimeister 2002-05-31
  • 打赏
  • 举报
回复
select count(*) as TOTAL form person where sex="人妖";
xhping801216 2002-05-31
  • 打赏
  • 举报
回复
这句话我也知道,能不能给一个比较完整点的例子呢?
skimeister 2002-05-31
  • 打赏
  • 举报
回复
select count(*) as TOTAL form xxxxxxxx where xxxxxxxxxx

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧