我有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 |
+----------------+-------------+------+-----+-------------------+---------
答案 0 :(得分:1)
create_time&lt; ='2017-07-31'表示create_time&lt; ='2017-07-31 00:00:00'(当日开始)
您的数据可能介于“2017-07-31 00:00:00”和“2017-07-31 14:30:00”之间
运行查询以检查上述时间间隔内是否有数据。