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;

相关推荐
Rverdoser22 分钟前
【SQL】多表查询案例
数据库·sql
Galeoto25 分钟前
how to export a table in sqlite, and import into another
数据库·sqlite
人间打气筒(Ada)1 小时前
MySQL主从架构
服务器·数据库·mysql
leegong231111 小时前
学习PostgreSQL专家认证
数据库·学习·postgresql
喝醉酒的小白1 小时前
PostgreSQL:更新字段慢
数据库·postgresql
敲敲敲-敲代码1 小时前
【SQL实验】触发器
数据库·笔记·sql
和道一文字yyds1 小时前
MySQL 中的索引数量是否越多越好?为什么?如何使用 MySQL 的 EXPLAIN 语句进行查询分析?MySQL 中如何进行 SQL 调优?
数据库·sql·mysql
落笔画忧愁e2 小时前
FastGPT快速将消息发送至飞书
服务器·数据库·飞书
Σίσυφος19002 小时前
halcon 条形码、二维码识别、opencv识别
前端·数据库
小刘|3 小时前
深入理解 SQL 注入漏洞及解决方案
数据库·sql