Sql Server 与 MySql 在使用 update inner join 时的区别

Sql Server

-- 不使用别名
UPDATE
    tb_User 
SET 
    tb_User.pass = ''
FROM 
    tb_User usr
INNER JOIN 
    tb_Address addr 
ON 
    usr.nAddressFK = addr.nAddressID
WHERE
    usr.id=123

-- 使用别名
UPDATE 
    usr 
SET 
    usr.pass = ''
FROM 
    tb_User usr
INNER JOIN 
    tb_Address addr 
ON 
    usr.nAddressFK = addr.nAddressID
WHERE
    usr.id=123

 

MySql

UPDATE 
    mem_world AS mw1 
INNER JOIN 
    mem_world AS mw2 
ON 
    mw1.parentid = mw2.wid 
SET 
    mw1.level = mw2.level 
WHERE 
    mw2.baseid = 107 
AND 
    mw2.parentid = 0 
AND 
    mw2.size > 1

 

 

一个是先 SET 再关联,另外一个是先关联再 SET。

posted @ 2017-04-06 15:16  宁采桃花不采臣  阅读(4058)  评论(0编辑  收藏  举报