2017-05-11 146 views
-3

我們可以通過從where子句中的其他表中獲取值來使用update子句中的where子句。更新中的Where子句

+2

的可能的複製[如何從UPDATE在SQL Server中的SELECT?](http://stackoverflow.com/questions/2334712/how-to-update-from-a-select-in-sql-server) –

+0

那麼,這取決於你想要什麼做。向我們展示您的查詢嘗試! – jarlh

回答

0

幾個選項,編輯您的更好的反應的問題提供更多的信息.​​..

update MyTable 
set MyColumn = 'Chicken Nuggets' 
where SomeColumn in (select SomethingElse from AnotherTable) 

或存在(一個更好的選擇):

update MyTable 
set MyColumn = 'Chicken Nuggets' 
where exists (select 1 from SomeOtherTable where SomethingElse = SomeColumn)