create table #warehouse(item sysname, feature nvarchar(100)) create table #fruit(fname sysname, color sysname) insert #fruit select 'apple', 'green' insert #fruit select 'melon', 'lime' insert #fruit select 'orange', 'orange' insert #fruit select 'grape', 'purple' insert #warehouse(item) select fname from #fruit -- update 1 update a set a.feature = 'color = ' + b.color from #warehouse a join #fruit b on a.item = b.fname select * from #warehouse -- update 2 update #warehouse set feature = 'new feature = ' + (select top 1 color from #fruit b where #warehouse.item = b.fname) select * from #warehouse drop table #warehouse, #fruit
conditional update
最新推荐文章于 2023-12-18 07:29:43 发布