我需要更新表中的特定行,要选择此行我需要使用内连接,我写道:
UPDATE Items
SET [Seq] = '0'
WHERE EXISTS
(SELECT *
FROM Items
inner join Dictionary on items.Member = Dictionary.Member WHERE
Items.ID = '1' and Items.Member ='23')
Items 表中的所有行都已更新,而不是特定行(select语句正常工作,我得到了我需要的行)
我错过了什么吗?
答案 0 :(得分:2)
Sql Server
UPDATE Items
SET Items.[Seq] = '0'
FROM Items inner join Dictionary
on items.Member = Dictionary.Member
WHERE Items.ID = '1' and Items.Member ='23'
<强> Mysql的强>
UPDATE Items
INNER JOIN Dictionary
ON items.Member = Dictionary.Member
SET Items.[Seq] = '0'
WHERE Items.ID = '1' and Items.Member ='23'
答案 1 :(得分:1)
在Sql Server中,格式为:
Update a
set field1 = b.field2
from table1 a
join table2 b on a.id = b.table1id
where b.somefield = 'test'