set t.agent_key = (select ngcc_sz.ngcc_id from ngcc_sz where ngcc_sz.icd_id=t.agent_key)
where exists (select ngcc_sz.ngcc_id from ngcc_sz where ngcc_sz.icd_id=t.agent_key);
update userinfo t set t.id=(select tt.ngcc_id from (SELECT *
FROM ngcc_sz_qc s
WHERE NOT EXISTS (SELECT *
FROM userinfo t
WHERE EXISTS (SELECT *
FROM ngcc_sz_qc n
WHERE t.id = n.ngcc_id)
AND t.id = s.ngcc_id)) tt where t.id=tt.icd_id),t.userid=(select tt.ngcc_id from (SELECT *
FROM ngcc_sz_qc s
WHERE NOT EXISTS (SELECT *
FROM userinfo t
WHERE EXISTS (SELECT *
FROM ngcc_sz_qc n
WHERE t.userid = n.ngcc_id)
AND t.id = s.ngcc_id)) tt where t.id=tt.icd_id)
where exists (select tt.ngcc_id from (SELECT *
FROM ngcc_sz_qc s
WHERE NOT EXISTS (SELECT *
FROM userinfo t
WHERE EXISTS (SELECT *
FROM ngcc_sz_qc n
WHERE t.userid = n.ngcc_id)
AND t.id = s.ngcc_id)) tt where t.id=tt.icd_id)