pgsql update select 查询并更新数据

复制代码
with t as (select id,
                  birthday,
                  identification,
                  substring(identification, 7, 8),
                  concat_ws('-', substring(substring(identification, 7, 8), 1, 4),
                            substring(substring(identification, 7, 8), 5, 2),
                            substring(substring(identification, 7, 8), 7, 2)
                      ) as a
           from app_public.users
           where
               identification is not null
               and
               identification != ''
           )
UPDATE app_public.users t1
SET birthday = t.a
FROM t
WHERE t1.id = t.id;

-- select * -- from t;

相关推荐
hqxstudying27 分钟前
MyBatis 和 MyBatis-Plus对比
java·数据库·mysql·mybatis
DarkAthena41 分钟前
AI生成技术报告:GaussDB与openGauss的HTAP功能全面对比
数据库·gaussdb
DemonAvenger2 小时前
高效JOIN操作:多表关联查询技巧与实战经验分享
数据库·mysql·性能优化
小云数据库服务专线3 小时前
GaussDB 数据库架构师修炼(十八) SQL引擎-分布式计划
数据库·数据库架构·gaussdb
秋已杰爱4 小时前
Redis分布式锁
数据库·redis·分布式
烟锁池塘柳05 小时前
【R语言】R语言中 rbind() 与 merge() 的区别详解
sql·r语言
haogexiaole11 小时前
Redis优缺点
数据库·redis·缓存
在未来等你11 小时前
Redis面试精讲 Day 27:Redis 7.0/8.0新特性深度解析
数据库·redis·缓存·面试
新法国菜13 小时前
MySql知识梳理之DML语句
数据库·mysql
老华带你飞13 小时前
校园交友|基于SprinBoot+vue的校园交友网站(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·校园交友网站