gpt4 book ai didi

mysql - 同时更新 3 列 2nd 表所有字段 varchar 更新电话号码的帮助

转载 作者:可可西里 更新时间:2023-11-01 07:44:04 25 4
gpt4 key购买 nike

UPDATE db2.customer e1 
SET
(
e1.userId,
e1.Email Id,
e1.Date of birth
)=
(SELECT ur.userId,ur.emailId,ur.dob FROM db1.user ur WHERE db1.user.mobileNo=db2.customer.mobile NO )

数据库 1st 和用户表

mobileNo      | userId  |emailId              | dob 
---------------------------------------------------------
1111111111 | 1 | cve@gmail.com |30-12-2013
2222222222 | 2 | ehs@gmail.com |20-12-2012
5555555555 | 3 | hsdj@gmail.com |01-12-2013
6666666666 | 4 | tr@gmail.com |02-12-2010

数据库第二表客户

mobile No    | userId         |    Email Id          | Date of birth 
--------------------------------------------------------------------
1111111111 | null | null |null
2222222222 | null | null |null
3333333333 | null | null |null
7777777777 | null | null |null

我想更新我的 db2.customer,其中电话号码与所有更新用户 ID、电子邮件 ID、出生日期匹配

我的查询不起作用---

最佳答案

试试这个:

UPDATE db2.customer e1 
INNER JOIN db1.user ur ON e1.mobileNo = ur.`mobile NO`
SET e1.userId = ur.userId,
e1.`Email Id` = ur.EmailId,
e1.`Date of birth` = ur.dob;

关于mysql - 同时更新 3 列 2nd 表所有字段 varchar 更新电话号码的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34648178/

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