devxlogo

Updating Two Tables

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?

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist