gpt4 book ai didi

mysql - SQL 使用另一个数据库中的值更新 1 个数据库中表中的值

转载 作者:行者123 更新时间:2023-11-30 00:53:09 25 4
gpt4 key购买 nike

我有两个不同的数据库。我需要从信息数据库更新审计数据库中的名称,其中 person_id = Patient_num。

数据库:审核

Table: person

person_id name
1 null
2 null
3 null

数据库:信息

Table: patient

patient_num patient_name
3 bob
1 nancy
2 sara

我一直在查看其他帖子,但我没有运气找到引用其他数据库的人。

最佳答案

您想要将updatejoin结合使用。 MySQL 中的语法为:

update audit.person pe join
info.patient pa
on pe.person_id = pa.patient_num
set pe.name = pa.patient_name
where pe.name is null;

关于mysql - SQL 使用另一个数据库中的值更新 1 个数据库中表中的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20802215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com