SQL数据表连接

UPDATE hj_cy_jws u   
set yyid = (   
            SELECT hj.yyid    
            FROM hj_cy_jws jw JOIN hj_cy hj ON jw.grid = hj.grid    
            WHERE u.id = jw.id   
            ) 




UPDATE hj_cy_jws u   
set yyid = (   
            SELECT DISTINCT hj.yyid    
            FROM hj_cy_jws jw JOIN hj_cy hj ON jw.grid = hj.grid    
            WHERE u.grid = hj.grid   
            )   
WHERE EXISTS (   
              SELECT * FROM hj_cy_jws jw JOIN hj_cy hj ON jw.grid = hj.grid   
              WHERE u.grid = hj.grid   
              )  



你可能感兴趣的:(二张表数据复制)