序幕:
数据库中有一个表,主要字段service_time[тип поля:time]为 , master[тип поля:varchar], date[тип поля:date], time[тип поля:time]。由于通过查询直接修改表(由于我自己的愚蠢,但修复它已经为时已晚)UPDATE,我认为数据库的完整性受到了损害。这将导致不可逆转的逻辑故障。
存储数据示例:
create table cl
(
ID_client int auto_increment
primary key
service_time time not null,
master varchar(24) not null,
date date not null,
time time not null,
);
INSERT INTO cl (service_time, master, date, time) VALUES ('02:00:00', 'Lana', '2020-07-18', '14:30:00');
INSERT INTO cl (service_time, master, date, time) VALUES ('02:00:00', 'Lana', '2020-07-19', '14:30:00');
INSERT INTO cl (service_time, master, date, time) VALUES ('02:00:00', 'Lana', '2020-07-18', '15:00:00');
INSERT INTO cl (service_time, master, date, time) VALUES ('02:00:00', 'Lana', '2020-07-18', '16:45:00');
INSERT INTO cl (service_time, master, date, time) VALUES ('02:00:00', 'Alex', '2020-07-07', '20:00:00');
要求:
为了检查表的逻辑值是否受到影响,您需要一个查询,该查询将返回表中的行,其中time+service_time将小于time同一天的下一个行,对于同一个主控。
上面存储数据的示例响应:
| service_time | master | date | time |
| 02:00:00 | Lana | 2020-07-18 | 14:30:00 |
| 02:00:00 | Lana | 2020-07-18 | 15:00:00 |
| 02:00:00 | Lana | 2020-07-18 | 16:45:00 |
当然,不是问题。
小提琴
相反
ID_client,您可以显示任何字段 - 初始字段和计算字段。