I am trying to check for the ID
. If it does not exist I want my data to be inserted as a new record in table and if ID
exists I want to compare both incoming new record and existing record and only update the values which are null
in existing record. I have written the query but I don't know how to check for null
in each column:
Here is the query:
insert into ui_table(MDMID,FirstName,Lastname,Mail,Address,City,State,Zip,ProfileStatus,TAID)
select im.MDMID,im.FirstName,im.Lastname,im.Mail,im.Address,im.City,im.State,im.Zip,im.ProfileStatus,im.TAID
from intermediate im on duplicate key update
MDMID = im.MDMID,
FirstName = im.FirstName,
Lastname = im.Lastname,
Mail = im.Mail,
Address = im.Address,
City = im.City,
State = im.State,
Zip = im.Zip,
ProfileStatus = im.ProfileStatus,
TAID = im.TAID;