开发者

UPDATE SQL based on 2 conditions

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜