当前位置: 首页 > 网络学院 > 服务端脚本教程 > SQL > SQL 的 COUNT(*) 函数

SQL
SQL Create View
SQL Server
SQL 速查
SQL 摘要
MYSQL 列类型存储需求

SQL 的 COUNT(*) 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 427 ::
收藏到网摘: n/a

The COUNT(*) function returns the number of selected rows in a selection.
使用COUNT(*)函数可以将在选择范围内的所有记录行数返回出来。

语法

SELECT COUNT(*) FROM table

举例

With this "Persons" Table:
通过这张"Persons"表:

Name Age
Hansen, Ola 34
Svendson, Tove 45
Pettersen, Kari 19

This example returns the number of rows in the table:
这个举例将返回表内记录行的数量:

SELECT COUNT(*) FROM Persons

结果:

3

举例

Return the number of persons that are older than 20 years:
返回个人信息中年纪大于20岁的记录数:

SELECT COUNT(*) FROM Persons WHERE Age>20

结果:

2

评论 (0) All

登陆 | 还没注册?