2017-06-02 55 views

回答

0

使用下面的查詢多個更新:

UPDATE A SET userid = '1,2,3' , userrolesid = '1,2,3' 
    WHERE id = 40 

注:這兩個更新列必須VARCHAR數據類型。

+0

將其更正爲'id = 40'。 – 2017-06-02 04:21:43

+0

@ aendeerei,謝謝 – Mansoor

+0

不客氣。 – 2017-06-02 04:27:52

0
WITH Tmp(id, px, py) AS (VALUES(id1, newsPosX1, newPosY1), 
           (id2, newsPosX2, newPosY2), 
           ......................... , 
           (idN, newsPosXN, newPosYN)) 

UPDATE TableToUpdate 
SET posX = (SELECT px 
      FROM Tmp 
      WHERE TableToUpdate.id = Tmp.id), 
    posY = (SELECT py 
      FROM Tmp 
      WHERE TableToUpdate.id = Tmp.id) 
WHERE id IN (SELECT id FROM Tmp) 
+0

你是怎麼想到這樣的答案的,而OP就像更新字段一樣簡單? – maSTAShuFu