示例表mingyan
mingyanSQL COUNT(column_name) 语法
COUNT(column_name) 函数返回指定列的值的数目(NULL 不计入):
示例:SELECT count(tag) FROM mingyan WHERE tag = 'xiaoli'
SQL COUNT(*) 语法
COUNT(*) 函数返回表中的记录数:
示例:SELECT count(*) FROM mingyan 结果:9
SQL COUNT(DISTINCT column_name) 语法
COUNT(DISTINCT column_name) 函数返回指定列的不同值的数目:
示例:SELECT count(DISTINCT tag) FROM mingyan
查询重复的记录并分组
select remark,count(*),GROUP_CONCAT(id) from t_banner group by remark HAVING count(*)>1
网友评论