--
-- ### Extended between checks
-- 
drop if exists table t1;
create table t1(a int not null,
       b int not null,
       c int not null);

drop if exists table t2;
create table t2(d int not null,
       e int not null);


insert into t1 values ( 1, 2, 3);
insert into t1 values ( 2, 7, 10); -- d match
insert into t1 values ( 3, 9, 10); -- d match
insert into t1 values ( 4, 9, 12); -- d match

insert into t2 values ( 2, 9);
insert into t2 values ( 3, 9);
insert into t2 values ( 4, 12);

select a from t1 where b between 1 and 3;

-- result should be 2,3,4
select a from t1 where a in ( select d from t2 where e between b and c );

-- result should be 4
select a from t1 where a in ( select d from t2 where e between 11 and 12 );

-- result should be 4
select a from t1 where a in ( select d from t2 where e between 11 and c );

-- result should be 2,3,4
select a from t1 where a in ( select d from t2 where e between b and 12 );

