字段重复判断
select ifnull( (SELECT '已存在该手机号码,请勿重复添加!'from b_staff_temp as staff left join b_unit_temp as unit on unit.id = staff.unit_id where unit.unit_status in (1,2) and staff.phone = #{phone} and staff.id != #{id__old} limit 1) ,ifnull((SELECT '已存在该证件号码,请勿重复添加!' from b_staff_temp as staff left join b_unit_temp as unit on unit.id = staff.unit_id WHERE unit.unit_status in (1,2) and staff.id_no = #{id_no} and staff.id != #{id__old} limit 1),'')) as message, ifnull( (SELECT count(1) from b_staff_temp as staff left join b_unit_temp as unit on unit.id = staff.unit_id WHERE unit.unit_status in (1,2) and (staff.phone = #{phone} or staff.id_no = #{id_no})),0) as valid
吾乃代码搬运工,侵联删