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;

相关推荐
Elastic 中国社区官方博客4 分钟前
ES|QL METRICS_INFO 和 TS_INFO:为你的时间序列数据建立目录
大数据·数据库·elasticsearch·搜索引擎·信息可视化·全文检索
俺不要写代码35 分钟前
数据库:函数
数据库·mysql
2401_8822737240 分钟前
如何在 CSS 中正确加载本地 JPG 背景图片
jvm·数据库·python
曹牧1 小时前
SQL:多个事务同时修改同一索引块
数据库·sql
aXin_ya1 小时前
微服务第八天 Sentinel 四种分布式事务模式
java·数据库·微服务
Ruci ALYS1 小时前
MySQL大小写敏感、MySQL设置字段大小写敏感
数据库·mysql
Lee川1 小时前
Prisma 实战指南:像搭积木一样设计古诗词数据库
前端·数据库·后端
极创信息2 小时前
信创产品认证怎么做?信创产品测试认证的主要流程
java·大数据·数据库·金融·软件工程
lzhdim3 小时前
SQL 入门 12:SQL 视图:创建、修改与可更新视图
java·大数据·服务器·数据库·sql