2012-06-28 45 views

回答

1

試試這個:

UPDATE table2 
SET someColumn = 'somevalue' 
WHERE EXISTS(SELECT * FROM table1 WHERE group_id='8') 
AND usertype='numbereight' 
+0

它用你的編輯0行 –

1

你可以用這樣的嘗試:

UPDATE table2 
SET (...) 
WHERE usertype='number eight' AND EXIST(SELECT * FROM table1 WHERE group_id='8'); 
1

嘗試

UPDATE table2 
SET (...) 
WHERE usertype = 'numbereight' 
AND exists (select * from table1 where group_id = '8') 
1

你可以加入表格並更新您需要的任何字段

UPDATE t1 JOIN t2 ON t1.id = t2.id 
SET 
    t2.field = 'whatever' 
WHERE 
    t1.group_id= '8' AND 
    t2.usertype = 'numbereight' 
+0

這是假設有一個共同的ID加入。如果您查看原始問題/ SQL,則沒有相關的ID /數據,因此這不起作用。 –

+0

@StevenMastandrea你是對的。我認爲表格是有關聯的 – Jeff

相關問題