繁体   English   中英

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

[英]Update 3 column in same time 2nd table all field varchar update help of phone number

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 ) 

数据库1和用户表

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 ,其中电话号码匹配所有更新userId,电子邮件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;
  UPDATE db2.customer e1
   SET e1.userId = e2.userId, 
   e1.Email Id=e2.Email Id,
   e1.Date of birth=e2.Date of birth
   FROM db1.user as 'e2'
    WHERE
    db1.user.mobileNo=db2.customer.mobileNO;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM