【问题标题】:Incorrect syntax near the keyword 'AS'. in SQL Server [duplicate]关键字“AS”附近的语法不正确。在 SQL Server [重复]
【发布时间】:2019-05-07 16:49:58
【问题描述】:

我的 SQL Server 查询有问题:

UPDATE latihan AS t1 ,
       (SELECT Equipment, system_status, functloc 
        FROM latihan 
        WHERE system_status='ESTO') AS t2 
SET t1.functloc = t2.functloc
WHERE t1.supereq = t2.equipment

我只想在基于functloc 的设备上更新functloc supereq

错误是:

[Err] 42000 - [SQL Server]关键字“AS”附近的语法不正确。
42000 - [SQL Server]关键字“AS”附近的语法不正确。

【问题讨论】:

    标签: sql-server


    【解决方案1】:

    我想你想要这样的东西:

    update t1 set
      functloc = t2.functloc
    from latihan t1
    inner join (
      select Equipment, system_status, functloc
      from latihan
      where system_status='ESTO'
    ) t2 on t2.equipment = t1.supereq
    

    【讨论】:

      猜你喜欢
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 2021-11-19
      • 1970-01-01
      • 2020-12-18
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      相关资源
      最近更新 更多