• count(1) count(*)


    mysql> select 1 from t;
    +---+
    | 1 |
    +---+
    | 1 |
    | 1 |
    | 1 |
    | 1 |
    +---+
    4 rows in set (0.00 sec)
    mysql> select count(1) from t;    
    +----------+
    | count(1) |
    +----------+
    |        4 |
    +----------+
    1 row in set (0.00 sec)
    mysql> select count(*) from t; 
    +----------+
    | count(*) |
    +----------+
    |        4 |
    +----------+
    1 row in set (0.00 sec)
    mysql> select count(a) from t; 
    +----------+
    | count(a) |
    +----------+
    |        4 |
    +----------+
    1 row in set (0.00 sec)
    mysql> explain  extended SELECT count(*) FROM `employees`;
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    | id | select_type | table     | type  | possible_keys | key     | key_len | ref  | rows   | filtered | Extra       |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    |  1 | SIMPLE      | employees | index | NULL          | PRIMARY | 4       | NULL | 299689 |   100.00 | Using index |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    1 row in set, 1 warning (0.17 sec)
    
    mysql> show warnings;
    +-------+------+---------------------------------------------------------------------------+
    | Level | Code | Message                                                                   |
    +-------+------+---------------------------------------------------------------------------+
    | Note  | 1003 | /* select#1 */ select count(0) AS `count(*)` from `employees`.`employees` |
    +-------+------+---------------------------------------------------------------------------+
    1 row in set (0.17 sec)
    
    mysql> explain  extended SELECT count(1) FROM `employees`; 
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    | id | select_type | table     | type  | possible_keys | key     | key_len | ref  | rows   | filtered | Extra       |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    |  1 | SIMPLE      | employees | index | NULL          | PRIMARY | 4       | NULL | 299689 |   100.00 | Using index |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    1 row in set, 1 warning (0.00 sec)
    
    mysql> show warnings;
    +-------+------+---------------------------------------------------------------------------+
    | Level | Code | Message                                                                   |
    +-------+------+---------------------------------------------------------------------------+
    | Note  | 1003 | /* select#1 */ select count(1) AS `count(1)` from `employees`.`employees` |
    +-------+------+---------------------------------------------------------------------------+
    1 row in set (0.00 sec)
  • 相关阅读:
    第8.13节 Python类中内置方法__repr__详解
    Python中splitlines方法判断文本中一行结束除了回车换行符是否还有其他字符?
    Python中使用eval执行下面函数的结果怎么是字符串'10020'?
    第8.12节 Python类中使用__dict__定义实例变量和方法
    ThinkPHP---thinkphp拓展之空操作
    ThinkPHP---TP功能类之邮件
    ThinkPHP---案例--实现知识管理功能
    ThinkPHP---TP功能类之公文管理功能2----------继续完善
    ThinkPHP---TP拓展之获取IP信息
    ThinkPHP---layer插件
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5635908.html
Copyright © 2020-2023  润新知