All pastes #369108 Raw Edit

Stuff

public text v1 · immutable
#369108 ·published 2007-02-23 16:00 UTC
rendered paste body
select distinct(candidates.id) as cid, first_name, last_name, direct_line,
                  offices.phone_number, subscriptions.id, countries.name, callbacks.date
              from candidates left join subscriptions
              on candidates.id = subscriptions.candidate_id
              join offices
              on candidates.office_id = offices.id
              join countries
              on offices.country_id = countries.id
              left join callbacks
              on callbacks.candidate_id = candidates.id
              where subscriptions.id is null
              and candidates.is_included = 1
              and candidates.editorial_board = 0
              and candidates.flag_moved = 0
              and not (candidates.id = 27828 or candidates.id = 28386 or candidates.id = 28133 or candidates.id = 28469)
              and not (phone_number = '' AND direct_line = '')
              and candidates.flag_for_delete = 0
              and countries.mail_zone = 1
              and candidates.id not in (select candidates.id from candidates, callbacks
                where candidates.id = callbacks.candidate_id and callbacks.flag_subscription = 1
                and candidates.is_included = 1 and callbacks.date >= now())
              group by candidates.id
              order by #{order}
              limit #{start}, 1000