You are here: updating multiple fields « MsSQL Server « IT news, forums, messages
updating multiple fields

Posted by calan on 10/01/77 11:27

How can I update each record in a table, based on a value in another table
with a single SQL statement?

For example, suppose I have the following two tables:

Table1

Name Something Color
-----------------------------------------
John GHAS Blue
John DDSS Blue
John EESS Blue
Paul xxxx Red
Ringo HJKS Red
Ringo FFFS Red
Sara hjkd Purple
Sara TTHE Purple
Jimi sdkjls Green


Table2

Name Color
------------------------
John ?
Paul ?
Ringo ?
Sara ?
Jimi ?


How can I update the color field in table 2 to correspond with the color
field in table1 (so I can normalize the db and delete the color field from
table1)?

I know I could open table2 and loop through within my app; just wondering
about a single SQL statement that would do it. I need a similar technique in
other places as part of my app.

Thanks,

Calan

 

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

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