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
drop table if exists t;

create table t
(id int auto_increment primary key, from_dt date,to_dt date);

insert into t (from_dt,to_dt) values ('20.04.2020' , '20.05.2020');

select * from t;
set @from = '2020-04-20';
set @to = '2020-05-20';

delete from t where id > 1;

insert into t (from_dt,to_dt)
select @from,@to
where not exists
(select 1
from t
where @from between from_dt and to_dt or
@to between from_dt and to_dt or
(from_dt between @from and @end) or
(to_dt between @from and @end) or
(@from < from_dt and @to > to_dt)
);

select * from t;


id from_dt to_dt
1 2020-04-20 2020-05-20
id from_dt to_dt
1 2020-04-20 2020-05-20