add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version()
8.0.27
create table buses (id_bus int, `пробег` int, `готовность` int);
create table `историято` ( `Тип ТО` int, `пробег` int, `Код ТО` int, id_bus int);
create table `категориито` (`Код ТО` int, `периодичность` int);
CREATE DEFINER = CURRENT_USER TRIGGER `mydbftest`.`buses_BEFORE_UPDATE` BEFORE UPDATE ON `buses` FOR EACH ROW
BEGIN
declare sumP int;
set sumP = ((select историято.пробег from историято where историято.id_bus = NEW.id_bus)+
(select категориито.периодичность from категориито where `Код ТО` =(select историято.Код ТО from историято
where историято.id_bus = NEW.id_bus)));
if sumP >NEW.пробег then set NEW.готовность = 1;
else set NEW.готовность = 0;
end if;
END
TRIGGER command denied to user 'u_179759978'@'localhost' for table 'buses'