?
Solved

How can I do this update statement?

Posted on 2016-08-11
2
Medium Priority
?
71 Views
Last Modified: 2016-08-18
I've got a "features" table with a "part_number" column in it that needs to be updated according to the "feature_door_id" column in the "doors" table.

There isn't a real relationship between those two tables, however...

There's a "product_id" column in the "products" table that can help, I just don't know how to structure this update statement that makes the correct association.

It looks like this:

spreadsheet image
I want to use the relationship that exists between the three tables to help me update what's in the "featured_door_id" column to the "part_number" column in the features table.

How?
0
Comment
Question by:brucegust
2 Comments
 
LVL 12

Accepted Solution

by:
funwithdotnet earned 2000 total points
ID: 41753211
Maybe I missed something. It looks like you have a related product_id column in both the doors and features tables.

If that is the case, in T-SQL it would look like this:

UPDATE f
SET f.part_number = d.featured_door_id
FROM [featurestable] f
INNER JOIN [doorstable] d ON d.product_id = f.product_id

Open in new window


Good luck!
0
 

Author Comment

by:brucegust
ID: 41760848
I figured it out, fun!

Thanks for your help!
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question