bugged.be

"Think outside the [B0X]"
Icon

Sql join update

The mssql way:

update user_asset_tag 
set uat.assetTypeId = ua.assetTypeId
from user_asset_tag uat
join user_asset ua on ua.id = uat.userAssetId

The Oracle way:

update (
  select ua.*
  , uat.AssetTypeId as assetTypeId2
  from user_asset ua
  join user_asset_tag uat on uat.userassetid = ua.id
)o 
set o.assetTypeId2 = o.assetTypeId

Category: Dev notes, Sql

Tagged: