我有一个带有一个名为data的表的mysql DB,
[After 10 minutes...]
twilio.js:1843 [Connection] Received HANGUP from gateway
当我尝试选择特定的日期范围时,例如今天,查询会返回超出日期范围的数据。
mysql> describe data;
+-------+---------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------------+------+-----+-------------------+----------------+
| idx | int(11) | NO | PRI | NULL | auto_increment |
| ts | timestamp | NO | | CURRENT_TIMESTAMP | |
| id | tinyint(3) unsigned | NO | | NULL | |
| value | decimal(10,2) | YES | | NULL | |
+-------+---------------------+------+-----+-------------------+----------------+
我对MYSQL很新,所以希望这很容易解决,但我还没有找到解决方案(不是因为没有尝试)。
答案 0 :(得分:2)
问题是OR
。您可以使用括号,或只使用IN
:
SELECT *
FROM data
WHERE ts BETWEEN '2016-11-27 00:11:00' AND '2016-11-29 00:11:00' AND
id IN (0, 1)
ORDER BY ts ASC
LIMIT 10;