update security_user set sex='女' where id in (  select a.id from (  SELECT id , SUBSTR(ID_CARD,7,8),SUBSTR(ID_CARD,17,1),ID_CARD,birthday,sex from security_user   where LENGTH(ID_CARD) =18   and sex is null    and data_state=1 and (SUBSTR(ID_CARD,17,1))%2=0) a  );
SUBSTR(ID_CARD,17,1) 截取出判断性别的数字 
mysql根据身份证提取生日和性别
update security_user set sex='男' where id in (  select a.id from (  SELECT id , SUBSTR(ID_CARD,7,8),SUBSTR(ID_CARD,17,1),ID_CARD,birthday,sex from security_user   where LENGTH(ID_CARD) =18   and sex is null    and data_state=1 and (SUBSTR(ID_CARD,17,1))%2 !=0) a  );

mysql根据身份证提取生日和性别










update security_user  set birthday=SUBSTR(ID_CARD,7,8)   where LENGTH(ID_CARD) =18   and birthday is null ;

update  security_user set birthday=  CONCAT(left(birthday,4),'-',right(birthday,LENGTH(birthday)-4))  where LENGTH(birthday)=8 ;
update  security_user set birthday=  CONCAT(left(birthday,7),'-',right(birthday,LENGTH(birthday)-7))  where LENGTH(birthday)=9 ;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-12-10
  • 2022-01-18
  • 2021-09-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-02-26
  • 2021-12-20
相关资源
相似解决方案