zoukankan      html  css  js  c++  java
  • 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)
  • 相关阅读:
    起点中文网小说爬取-etree,xpath,os
    拉勾网爬虫--待改正
    破解有道词典翻译-版本二
    pycharm错误:11001
    自动化selenium 测试之道(一)
    valgrind 详细说明
    sar命令使用详解
    Linux CPU实时监控mpstat命令详解
    Linux IO实时监控iostat命令详解
    RPM安装命令总结
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5635908.html
Copyright © 2011-2022 走看看