数据源是:
Start Time Real End Time Staff
2013-02-14 16:44:27 2013-02-14 18:44:27 P
2013-02-14 16:44:08 2013-02-14 17:09:08 C
2013-02-14 16:42:51 2013-02-14 16:43:51 P
2013-02-14 16:31:26 2013-02-14 17:06:26 V
2013-02-14 16:04:02 2013-02-14 16:34:02 C
当我使用时:
CREATE VIEW turn_times AS
SELECT staff AS name, start_time, real_end_time AS work_end_time
FROM ( SELECT staff, start_time, real_end_time
FROM treatments
WHERE date(real_end_time) = curdate()
ORDER BY real_end_time ASC) AS a
GROUP BY name
我有:
mysql #1349 - View's SELECT contains a subquery in the FROM clause
我想通过使用 view获取以下数据,有什么好的解决方案:
name start_time work_end_time
C 2013-02-14 16:04:02 2013-02-14 16:34:02
P 2013-02-14 16:42:51 2013-02-14 16:43:51
V 2013-02-14 16:31:26 2013-02-14 17:06:26
我不想为这个问题创建两个视图,我可以在一个视图中获得正确的 sql 吗?