你的位置:首页 > 软件开发 > 数据库 > SQL查询符合条件的记录的总数

SQL查询符合条件的记录的总数

发布时间:2016-09-24 12:00:18
1. select count(*) from table; //统计元组个数2. select count(列名) from table; //统计一列中值的个数3. select count(*) from table where 字段 = &quot ...

1. select count(*) from table;    //统计元组个数

2. select count(列名) from table;  //统计一列中值的个数

3. select count(*) from table where 字段 = "";  //符合该条件的记录总数

4. sql_count = "select count(*) from article a where 1=1 ";

//这条语句中a就代表article 这张表,后面可以写a.字段来代表该表的字段,where 1 = 1,就相当于提供了一个where。因为1=1永远成立。

 就可以根据是否需要加条件,在该语句后面加and a.字段 = "", 等等。

例:

sql_count = "select count(*) from article a where 1=1 "; sql_count +="and a.a_title like '%"+title+"%'";

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:SQL查询符合条件的记录的总数

关键词:sql

sql
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。