All pastes #247178 Raw Edit

Something

public text v1 · immutable
#247178 ·published 2006-11-13 03:05 UTC
rendered paste body
select T1.name, T1.school
    from (select
              t.id as t_id
              , j.id as j_id
              , t.name
              , t.school
            from teachers as t
            inner
              join jobs as j
                on t.location = j.location
                and t.arival between date_sub( j.arrival, interval 20 day) and date_add( j.arrival, interval 20 day)
           ) as T1
    left outer
      join sent_match as s
        on s.teacher_id = T1.t_id
          and s.school_id = T1.j_id
    where s.teacher_id is null
      and s.school_id is null