MySQL、SQLServer、Oracle的update left join语法

mysql

UPDATE A  
LEFT JOIN  
 B  
ON   
 A.B_ID = B.B_ID  
SET   
 A.A_NAME = B.B_NAME;

sqlserver

update A  
set A_NAME = B.B_NAME  
from A left join B   
ON   
 A.B_ID = B.B_ID  

sqlserver注意 前面两个A没有别称

oracle

UPDATE (
    SELECT
        a.cont AS acont
    FROM
        A t
    LEFT JOIN B a ON t.id = a.id
    WHERE
        a.cont = '2452452'
) p
SET p.cont = '2';

 

posted @ 2018-07-18 18:14  start逍遥  阅读(3237)  评论(2编辑  收藏  举报