mysql里面的count()函數(shù)的問題
3 回答

慕勒3428872
TA貢獻1848條經(jīng)驗 獲得超6個贊
count() 僅僅是計算行數(shù)的.
僅僅當你 指定的列名里面, 有存在 NULL 的情況下,會對你的 COUNT 結果有影響。
下面是一個例子:
1> create table #t123(
2> id int,
3> val int
4> );
5> go
1> insert into #t123 values(1, null);
2> insert into #t123 values(null, 1);
3> insert into #t123 values(1, 1);
4> go
(1 行受影響)
1> select count(id), count(val), count(*), count(1) from #t123;
2> go
----------- ----------- ----------- -----------
2 2 3 3
警告: 聚合或其他 SET 操作消除了 Null 值。

HUWWW
TA貢獻1874條經(jīng)驗 獲得超12個贊
這個是用來輸出滿足where條件所有的行數(shù)。
你可以這么些
select count('remark') from table
where remark not null
- 3 回答
- 0 關注
- 933 瀏覽
添加回答
舉報
0/150
提交
取消