sql update table set - The multi-part identifier could not be bound

前端 未结 2 1024
傲寒
傲寒 2021-01-05 02:18

I have 2 tables:

  • Table1 = names of gas stations (in pairs)
  • Table2 = has co-ordinate information (longitude and latit
2条回答
  •  遥遥无期
    2021-01-05 02:46

    You need to change the inner table and give a different allias to the columns that are similar. This should work.

    update table1
    set [Lattitude1] = x.[lat]
    from 
    (
        SELECT IDInfo [id], Lattitude [lat] FROM 
        table2
    ) x
    WHERE
    StationID1 = x.[id]
    

    In your particular case its not necessary to rename Lattitude to lat, but if you end up updating a table with itself and force yourself into giving the columns different names, it will save you headaches down the road.

提交回复
热议问题