【问题标题】:Update rows where a combination of multiple attributes is IN the table更新表中多个属性组合的行
【发布时间】:2019-04-15 12:30:43
【问题描述】:

我想更新一个表的字段,其中三个其他属性的组合在另一个表中。我在语法上遇到了一些困难,因此不胜感激。

【问题讨论】:

  • 告诉我们您的尝试。

标签: sql conditional-statements where where-in


【解决方案1】:

您通常会为此使用EXISTS

SELECT *
FROM a
WHERE EXISTS (
    SELECT 1
    FROM b
    WHERE a.col1 = b.col1 AND a.col2 = b.col2 AND a.col3 = b.col3
)

将以上内容转换为UPDATE 查询。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    • 1970-01-01
    • 2019-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多