postgresql7.1 insert into ttl_area_assignments (area_id, user_id) select :area_id, :user_id where not exists (select 1 from ttl_area_assignments where user_id = :user_id and area_id = :area_id)