使用更新隐式联接?

时间:2019-02-08 10:51:52

标签: sql sql-server join

我试图基于主键更新表X中的列的值,以使其等于表Y中的值。我使用的是更新语句,但我认为我做错了很多事情,因为我收到以下错误消息:

  

“无法绑定多部分标识符”。

update [UK_Telco_Pressure_2018Q3_2019-01-31 W2] 
set Video_Name=[UK_Telco_Pressure_2018Q3_2019-01-31 WEEK1] 
where [UK_Telco_Pressure_2018Q3_2019-01-31 WEEK1].Updated_Campaign=[UK_Telco_Pressure_2018Q3_2019-01-31 W2].Updated_Campaign

4 个答案:

答案 0 :(得分:2)

通过CTE更新是这里的一种选择:

...
insecureSkipVerify= true

defaultEntryPoints = ["http", "https"]

[entryPoints]
    [entryPoints.http]
....

我看到您的语法有多个问题,但是我看到的最大问题是,您实际上并未从第二个表中指定要在更新中使用的列。

答案 1 :(得分:1)

使用加入

  update im  
    set im.Video_Name=im2.Video_Name
    from [UK_Telco_Pressure_2018Q3_2019-01-31 W2] im join
     [UK_Telco_Pressure_2018Q3_2019-01-31 WEEK1] im2 
 on im.Updated_Campaign=im2.Updated_Campaign

答案 2 :(得分:0)

$.ajax({
                    async: true,
                    url : "Servlet1?action=action1", // Here you set the parameter
                    method : "GET",
                    dataType : "json",
                    contentType: "application/json; charset=utf-8",  
                    success : function(tableValue) {
                     addTable(tableValue)                               
                    }                                
                });

在列名之前添加表名...

答案 3 :(得分:0)

我猜[UK_Telco_Pressure_2018Q3_2019-01-31 WEEK1]是一个表名。您需要在Set表达式中传递列名,如下所示,考虑上述表也有Video_Name列:

update [UK_Telco_Pressure_2018Q3_2019-01-31 W2] 
set Video_Name=[UK_Telco_Pressure_2018Q3_2019-01-31 WEEK1].Video_Name 
where [UK_Telco_Pressure_2018Q3_2019-01-31 WEEK1].Updated_Campaign=[UK_Telco_Pressure_2018Q3_2019-01-31 W2].Updated_Campaign