• 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)
  • 相关阅读:
    python3 TypeError: a bytes-like object is required, not 'str'
    Centos 安装Python Scrapy PhantomJS
    Linux alias
    Vim vimrc配置
    Windows下 Python Selenium PhantomJS 抓取网页并截图
    Linux sort
    Linux RSync 搭建
    SSH隧道 访问内网机
    笔记《鸟哥的Linux私房菜》7 Linux档案与目录管理
    Tornado 错误 "Global name 'memoryview' is not defined"
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5635908.html
Copyright © 2020-2023  润新知