Click here to Skip to main content
15,907,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
database 1st nd user table
--db1.user

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


database 2nd nd table customer
db2.customer

mobile No | userId | Email Id | Date of birth

1111111111 | null | null |null
2222222222 | null | null |null
3333333333 | null | null |null
7777777777 | null | null |null

i want update my db2.customer where phone number match all update userId ,Email Id ,Date of birth


my quarry not work---

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 )
Posted

1 solution

Try this

SQL
UPDATE db2.customer c
    INNER JOIN db1.user u
        ON c.mobileNo = u.mobileNo 
SET c.userId = u.userId,
    c.EmailId = u.EmailId,
    c.DateOfBirth = u.DOB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900