update a set a.entity_shdgl_id =b.id from entity_shdgl_CKXXLB a,entity_shdgl b where a.shdh=b.shdh and a.id in(
SELECT id from entity_shdgl_CKXXLB where id not in( SELECT id from Entity_SHDGL where id in (SELECT distinct entity_shdgl_id from entity_shdgl_CKXXLB)) and entity_shdgl_id is null and shdh not in(SELECT shdh from Entity_SHDGL where id in (SELECT entity_shdgl_id from entity_shdgl_CKXXLB ) )
)
SELECT id from entity_shdgl_CKXXLB where id not in( SELECT id from Entity_SHDGL where id in (SELECT distinct entity_shdgl_id from entity_shdgl_CKXXLB)) and entity_shdgl_id is null and shdh not in(SELECT shdh from Entity_SHDGL where id in (SELECT entity_shdgl_id from entity_shdgl_CKXXLB ) )
)