update d_bs_user set birth_date = SUBSTRING(id_card,7,8)
where id_card is not null and length(id_card)=18 and SUBSTRING(id_card,7,4)>'1900' and SUBSTRING(id_card,7,4)<'2100';
update d_bs_user set age =year(CURDATE()) - year(birth_date) where birth_date is not null;
mysql通过身份证号更新生日及年龄
于 2023-09-20 10:02:57 首次发布
文章描述了如何在SQL查询中使用函数如SUBSTRING和CURDATE()来更新用户表中的生日信息,并计算用户的年龄,条件是ID卡号的有效性(1900-2100年之间)。

8400

被折叠的 条评论
为什么被折叠?



