sql中count(*)和count(欄位名)區別詳解及用途,sqlcount

來源:互聯網
上載者:User

sql中count(*)和count(欄位名)區別詳解及用途,sqlcount
文章詳細利用執行個體來介紹了關於sql中count(*)和count(欄位名)區別有需要的同學可以參考一下下。

以前沒有注意兩者的區別,看部落格園的文章,還真引起了我的注意。

資料測試:見圖

sql 語句見分曉:

SELECT COUNT(*) c1 ,COUNT(ADDRESS) c2 FROM test

顯而易見,count(*)統計的是結果集的總條數,count(欄位名)統計的是該欄位值不為null的總條數

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.