Thursday, 30 August 2018
Subscribe to:
Post Comments (Atom)
USER
ID char(8)
LastName nvarchar(30)
FirstName nvarchar(30)
PostCode nvarchar(10)
PhoneNumber nvarchar(20)
HomeAdress nvarchar(20)
COMMAND
ID char(6)
CMD_FirstName nvarchar(20)
CMD_LastName nvarchar(20)
CMD_PostCode nvarchar(10)
ID_User char(8)
update c
set id_user = u.ID
from [user] u
join [command] c on c.cmd_firstname = u.firstname
and c.cmd_lastname = u.lastname
and c.cmd_postcode = u.postcode;
user
, you can pre-aggregate the user
table and filter those out.update c
set id_user = u.ID
from [command] c
join (select firstname, lastname, postcode, min(ID) ID
from [user]
group by firstname, lastname, postcode
having count(*) = 1) u
on c.cmd_firstname = u.firstname
and c.cmd_lastname = u.lastname
and c.cmd_postcode = u.postcode;
Hello Friends! I am Ramana a part time blogger from Hyderabad.
0 comments:
Post a Comment