开发者

UPDATE SQL based on 2 conditions

开发者 https://www.devze.com 2023-02-10 09:38 出处:网络
Given the following table structure Locations LocationName|Easting|Northing Incidents LocationString|Easting|Northing|LocationName

Given the following table structure

Locations

LocationName|Easting|Northing

Incidents

LocationString|Easting|Northing|LocationName

LocationString is a badly formatted Subway Station Name that the user of the application can type any old rubbish in to. The eastings and Northings (Co-ordinates) are consistent however. Using them i can give the location a consistent name by looking those values up in a look up table.

In ACCESS SQL i would do the following

UPDATE INCIDENTS, Locations
SET Incidents.LocationName = Locations.LocationsName
WHERE Incidents.Easting = Locations.Easting
AND
Incidents.Northing = Locations.Northing

How do i acc开发者_如何学JAVAomplish the same in T-SQL?


UPDATE I
SET I.LocationName = L.LocationsName
FROM Incidents I
JOIN Locations L
ON I.Easting = L.Easting AND I.Northing = L.Northing
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号