Skip to main content
2 of 3
added 77 characters in body
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)
      ) ;

Test at sqlfiddle.com.

ypercubeᵀᴹ
  • 98.7k
  • 13
  • 215
  • 305