← Tutti gli articoli
How-To Update Tables Using Inner Joins and Group By
05 March 2011 ·
TSQL · Recipe ·
158 visite
I'm making an update to my table Contents and would like to update the ContentDate coloumn in all the rows that have the minimum BeginDate in the ContentsHistory table.
UPDATE c SET c.ContentDate = hh.NewDate FROM Contents as c INNER JOIN (Select ContentId, MIN(BeginDate) as NewDate from ContentsHistory group by ContentId ) as hh on c.ContentId = hh.ContentId