在SQL Update中使用Distinct
这是我需要转换为更新的选择:
SELECT DISTINCT f.SectionID, f.Name, v.EnabledFROM SETTING_VALUE v
INNER JOIN SETTING s ON v.SettingID = s.SettingID
INNER JOIN LU_FIELD f ON f.FieldID = s.FieldID
WHERE v.DisplayValue LIKE '%Miami%'
AND f.ControlName LIKE '%City%'
我的尝试:
UPDATE SETTING_VALUESET Enabled = 0
FROM SETTING_VALUE v
INNER JOIN SETTING s ON v.SettingID = s.SettingID
INNER JOIN LU_FIELD f ON f.FieldID = s.FieldID
WHERE v.DisplayValue LIKE '%Miami%'
AND f.ControlName LIKE '%City%'
不确定如何申请Distinct
回答:
根据您的评论,all of the matching rows should be updated
您不需要区分。只需执行以下命令:
UPDATE SETTING_VALUESET Enabled = 0
FROM SETTING_VALUE v
INNER JOIN SETTING s ON v.SettingID = s.SettingID
INNER JOIN LU_FIELD f ON f.FieldID = s.FieldID
WHERE v.DisplayValue LIKE '%Miami%'
AND f.ControlName LIKE '%City%'
您选择的所有内容都会更新。
以上是 在SQL Update中使用Distinct 的全部内容, 来源链接: utcz.com/qa/412830.html