gpt4 book ai didi

sql - 在 SQL 更新中使用 Distinct

转载 作者:行者123 更新时间:2023-12-02 22:29:05 25 4
gpt4 key购买 nike

这是我需要转换为更新的选择:

SELECT DISTINCT f.SectionID, f.Name, v.Enabled
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%'

我的尝试:

UPDATE SETTING_VALUE
SET 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

最佳答案

根据您的评论,所有匹配的行都应该更新,您不需要区分。只需执行这个:

UPDATE SETTING_VALUE
SET 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 - 在 SQL 更新中使用 Distinct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7163271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com