字段重复判断

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 

 

posted on 2024-07-26 16:52  五官一体即忢  阅读(2)  评论(0编辑  收藏  举报

导航