Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Nov 23, 1999

Updating Two Tables

Question:
I have two tables:
  • Yarn {Y_yarn_code,x_code}y_yarn_code being PK
  • Yarn_lot (yl_yarn_code)
I need to update yl_yarn_code with x_code where y_yarn-code=yl_yarn_code

Answer:
Try this:

 
UPDATE Yarn_Lot 
SET Yarn_Lot.yl_yarn_code = 
(SELECT x_code 
   FROM Yarn
   WHERE Yarn.y_yarn_code = 
   Yarn_Lot.yl_yarn_code)
Is this what you intended?
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date