Mysql 查询差异
Mysql query discrepancy
我有 2 个 mysql 查询,但两个查询的结果不同,尽管第一个查询似乎给出了更多结果。
MySQL [mydb1]> select count(*) from user_id where
create_time>='2017-07-28' and create_time<='2017-07-31';
+----------+
| count(*) |
+----------+
| 65150086 |
+----------+
MySQL [mydb1]> select count(*) from user_id where
create_time>='2017-07-28 16:30:00' and create_time<='2017-07-31 14:30:00';
+----------+
| count(*) |
+----------+
| 79679998 |
+----------+
+----------------+-------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+-------------------+-----------------------------+
| id | bigint(11) | NO | PRI | NULL | auto_increment |
| user_id | varchar(45) | NO | UNI | NULL | |
| name | varchar(45) | YES | MUL | NULL | |
| create_time | datetime | YES | | NULL | |
| update_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+----------------+-------------+------+-----+-------------------+---------
create_time<='2017-07-31' 表示 create_time<='2017-07-31 00:00:00'(当天开始)
您的数据可能介于“2017-07-31 00:00:00”和“2017-07-31 14:30:00”之间
运行 查询以检查是否有上述间隔内的数据。
我有 2 个 mysql 查询,但两个查询的结果不同,尽管第一个查询似乎给出了更多结果。
MySQL [mydb1]> select count(*) from user_id where
create_time>='2017-07-28' and create_time<='2017-07-31';
+----------+
| count(*) |
+----------+
| 65150086 |
+----------+
MySQL [mydb1]> select count(*) from user_id where
create_time>='2017-07-28 16:30:00' and create_time<='2017-07-31 14:30:00';
+----------+
| count(*) |
+----------+
| 79679998 |
+----------+
+----------------+-------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+-------------------+-----------------------------+
| id | bigint(11) | NO | PRI | NULL | auto_increment |
| user_id | varchar(45) | NO | UNI | NULL | |
| name | varchar(45) | YES | MUL | NULL | |
| create_time | datetime | YES | | NULL | |
| update_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+----------------+-------------+------+-----+-------------------+---------
create_time<='2017-07-31' 表示 create_time<='2017-07-31 00:00:00'(当天开始)
您的数据可能介于“2017-07-31 00:00:00”和“2017-07-31 14:30:00”之间
运行 查询以检查是否有上述间隔内的数据。