我希望下面的错误是自我解释的。我想将event_time与几个cart_time进行比较。我知道通常当我们想要这样的任何操作时我们需要使用in
但是对于时间戳如何比较它< / p>
mysql> SELECT bsid
FROM access_aug15
WHERE event_time < (SELECT cart_time
FROM chat_final
WHERE bsid in (SELECT bsid
FROM access_aug15
WHERE eventid="11"
AND current_page not like '%cart%'));
ERROR 1242 (21000): Subquery returns more than 1 row
编辑:表格结构access_aug15
+-------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+-------+
| vid | varchar(200) | YES | | NULL | |
| bsid | varchar(200) | YES | MUL | NULL | |
| event_time | datetime | YES | MUL | NULL | |
| eventid | varchar(10) | YES | MUL | NULL | |
| current_page | mediumtext | YES | | NULL | |
| departmentid | varchar(100) | YES | MUL | NULL | |
| form_id | varchar(100) | YES | | NULL | |
| form_name | varchar(100) | YES | | NULL | |
| page_title | varchar(200) | YES | | NULL | |
| report_date | datetime | YES | MUL | NULL | |
+-------------------+--------------+------+-----+---------+-------+
表2:chat_final
+-------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+-------+
| bsid | varchar(200) | YES | MUL | NULL | |
| chat_time | datetime | YES | | NULL | |
| cart_time | datetime | YES | | NULL | |
| customerid | varchar(100) | YES | | NULL | |
| detail | longtext | YES | | NULL | |
| chat_type | varchar(5) | YES | | NULL | |
+-------------------+--------------+------+-----+---------+-------+
答案 0 :(得分:0)
在您的查询子查询(在另一个查询中查询)应该只返回一个结果..但它返回多行。您需要修改子查询。请提供表格结构和一些数据...然后我会给你正确的查询
答案 1 :(得分:0)
select bsid from access_aug15 where event_time <(select cart_time from chat_final
where bsid in (select bsid from access_aug15
where eventid="11" and current_page not like '%cart%'
LIMIT 1)
LIMIT 1);