我正在使用SQL Server,并尝试从同一个表中更新行.我想使用表别名来提高可读性.
这就是我现在这样做的方式:
UPDATE ra
SET ra.ItemValue = rb.ItemValue
FROM dbo.Rates ra
INNER JOIN dbo.Rates rb
ON ra.ResourceID = rb.ResourceID
WHERE ra.PriceSched = 't8'
AND rb.PriceSched = 't9'
有更简单/更好的方法吗?
UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra INNER JOIN dbo.Rates rb ON ra.ResourceID = rb.ResourceID WHERE ra.PriceSched = 't8' AND rb.PriceSched = 't9';
这可能有助于提高性能.