记录用
UPDATE XXX
SET w_apply_num = (select (CASE a.dot
WHEN 10 THEN CONCAT('CN',a.num,'.','X')
ELSE CONCAT('CN',a.num,'.',a.dot)
END) as dots
FROM
(select id,
(SUBSTRING(w_apply_num, 5, 1)*2 +
SUBSTRING(w_apply_num, 6, 1)*3 +
SUBSTRING(w_apply_num, 7, 1)*4 +
SUBSTRING(w_apply_num, 8, 1)*5 +
SUBSTRING(w_apply_num, 11, 1)*7 +
SUBSTRING(w_apply_num, 13, 1)*8 +
SUBSTRING(w_apply_num, 14, 1)*9 +
SUBSTRING(w_apply_num, 15, 1)*2 +
SUBSTRING(w_apply_num, 16, 1)*3 +
SUBSTRING(w_apply_num, 17, 1)*4 +
SUBSTRING(w_apply_num, 18, 1)*5 + 1*6)%11 as dot,CONCAT(SUBSTRING(w_apply_num, 5, 4),1,SUBSTRING(w_apply_num,11,7)) as num
from XXX where w_apply_num not LIKE '%.%') a where a.id =t_patent_info.id )
WHERE EXISTS (select (CASE a.dot
WHEN 10 THEN CONCAT(a.num,'.','X')
ELSE CONCAT(a.num,'.',a.dot)
END) as dots
FROM
(select id,
(SUBSTRING(w_apply_num, 5, 1)*2 +
SUBSTRING(w_apply_num, 6, 1)*3 +
SUBSTRING(w_apply_num, 7, 1)*4 +
SUBSTRING(w_apply_num, 8, 1)*5 +
SUBSTRING(w_apply_num, 11, 1)*7 +
SUBSTRING(w_apply_num, 13, 1)*8 +
SUBSTRING(w_apply_num, 14, 1)*9 +
SUBSTRING(w_apply_num, 15, 1)*2 +
SUBSTRING(w_apply_num, 16, 1)*3 +
SUBSTRING(w_apply_num, 17, 1)*4 +
SUBSTRING(w_apply_num, 18, 1)*5 + 1*6)%11 as dot,CONCAT(SUBSTRING(w_apply_num, 5, 4),1,SUBSTRING(w_apply_num,11,7)) as num
from XXX where w_apply_num not LIKE '%.%') a where a.id =XXX.id);