You are here: Re: Update query from another table on datechanged field « MsSQL Server « IT news, forums, messages
Re: Update query from another table on datechanged field

Posted by scoots987 on 11/26/07 05:16

On Nov 25, 10:27 pm, "Plamen Ratchev" <Pla...@SQLStudio.com> wrote:
> Assuming the <lastchanged> column belongs to table <main>, and there are no
> duplicate values for <lastchanged> per <ssn>, then the following update
> should do it:
>
> UPDATE group1
> SET address1 = c.address1,
> address2 = c.address2,
> city = c.city,
> state = c.state,
> zipcode = c.zipcode,
> country = c.country
> FROM group1 AS g
> JOIN main AS c
> ON g.ssn = c.ssn
> WHERE c.lastchanged = (SELECT MAX(c1.lastchanged)
> FROM main AS c1
> WHERE c1.ssn = c.ssn)
>
> HTH,
>
> Plamen Ratchevhttp://www.SQLStudio.com

Thank You! Worked like a charm.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация