Skip to main content
1 of 3
ypercubeᵀᴹ
  • 98.7k
  • 13
  • 215
  • 305

I think you want this:

select b.*                             -- show everything
from table_b b                         -- from table b
where not exists                       -- when
      ( select 1                       -- there is nothing
        from table_a a                 -- in table a with
        where a.road_id = b.road_id    -- same road,
          and a.year = b.year          -- same year and
          and a.from_m < b.to_m        -- overlapping
          and b.from_m < a.to_m        -- (from, to)
      ) ;
ypercubeᵀᴹ
  • 98.7k
  • 13
  • 215
  • 305