当前位置:网站首页>MySQL - the difference between count (field), count (primary key), count (1), count (*)
MySQL - the difference between count (field), count (primary key), count (1), count (*)
2022-07-29 02:53:00 【Husky who is not eager for power】
List of articles
count( Field )、count( Primary key )、count(1)、count(*) The difference between
- count() It's an aggregate function , Judge the returned result set line by line , If count The field value corresponding to the parameter in the function is not Null, Add... To the cumulative value 1, Otherwise, we will not add , Finally return the cumulative value .
- count(*)、count(1) and count( Primary key id) All return the total number of rows of the result set that meet the conditions ; and count( Field ), Then the value in the returned field is not Null The total number of rows of .
With weibo_user Table as an example , There are 99 Data ,created_at The field value is not Null Data are available. 6 strip
- count(*) Query all data
- count(id) Query all data
- count(1) Query all data
- count(create_at) Query only 6 Data , Values are not for NULL The data of
Execution efficiency
- If the data table has no primary key , that count(1) Than count() fast ;
- If there is a primary key , That's the primary key count It's better than count() Be quick ;
- If the table has only one field ,count(*) It's the fastest .
边栏推荐
- Analysis of Project-based Learning Creativity in steam Education
- etcd实现大规模服务治理应用实战
- Pgzero飞机大战
- 图书管理系统
- Ffmpeg+sdl+qt is a simple video player
- 双for循环
- 区区区间---线段树lazy标记板子题
- C language: judging letters
- Asemi rectifier bridge s25vb100, s25vb100 parameters, s25vb100 application
- 6-21 vulnerability exploitation MySQL weak password cracking
猜你喜欢

Cloud development workers must go to work fishing and paddling wechat applet source code

C language: Little Lele and Euclid

Interpretation of ue4.25 slate source code

Asemi rectifier bridge s25vb100, s25vb100 parameters, s25vb100 application

Flink内核源码(七)Flink SQL提交流程

QT屏幕自适应自动布局,拖动窗口自动变大变小(一)

laravel框架中实现封装公共方法全局调用

第五天实验

(作业)C语言:atoi和strncpy、strncat、strncmp的模拟实现

This blogger has a comprehensive classification of QT. If you are free, go to study and summarize it and record it.
随机推荐
(job) C language: Simulation Implementation of ATOI and strncpy, strncat, strncmp
QT screen adaptive automatic layout, drag the window to automatically grow larger and smaller (I)
Add a row to a specific location in the dataframe
ECCV 2022 | airdet: a small sample target detection method without fine tuning
Redis queue realizes second kill
owt-server源码剖析(四)--video模块分析之Mixer Out
第六天笔记
ASEMI整流桥S25VB100,S25VB100参数,S25VB100应用
.net serialize enumeration as string
Some records during the development of ros2/ros1
OSPF实验
Youxuan software appoints Huang Zhijun as the general manager of the company
以科技传递温度,vivo亮相数字中国建设峰会
【报错】node:internal/modules/cjs/loader:936 【解决方法】
Summary of classic problems in Flink production environment
Analysis of Project-based Learning Creativity in steam Education
并发模式之单例和不变模式
创客教育的起源和内涵的基本理念
Jinshan cloud returns to Hong Kong for listing: Hong Kong stock rush of Chinese to B cloud manufacturers
每周推荐短视频:如何让产品开发更加有效?




