You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
542 B
16 lines
542 B
-- 清理 t_employee 中重复邮箱(仅保留同邮箱组内 employee_id 最小的一条)
|
|
-- 背景:唯一性校验 getByEmail 使用 selectOne,若同邮箱存在多条未删除记录会触发 TooManyResultsException
|
|
|
|
UPDATE t_employee e
|
|
SET email = NULL,
|
|
update_time = NOW()
|
|
WHERE e.deleted_flag = false
|
|
AND e.email IS NOT NULL
|
|
AND trim(e.email) <> ''
|
|
AND EXISTS (
|
|
SELECT 1
|
|
FROM t_employee o
|
|
WHERE o.deleted_flag = false
|
|
AND o.email = e.email
|
|
AND o.employee_id < e.employee_id
|
|
);
|
|
|