Solved

Join 3 tables for an Update

Posted on 2012-03-25
4
413 Views
Last Modified: 2012-03-25
I have 3 tables.
I want update 2 fields in the Nop_Product table with data from the TempOne table,
based on the SKU field matching in the Nop_ProductVariant table.

(Brand, MetaTitle2, and SKU in TempOne table)

UPDATE Nop_Product
SET  SEName2 = Brand, MetaTitle2 = Category

But the Nop_ProductVariant table has the SKU field that matches the
SKU field in the TempOne table :


WHERE Nop_Product.[ProductId] IN
(SELECT Nop_ProductVariant.ProductId FROM Nop_ProductVariant

then join the SKU from TempOne table here ???

How do I do this? thanks
0
Comment
Question by:MikeMCSD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37763520
you can use something like

UPDATE
    Table
SET
    Table1.col1 = other_table.col1,
    Table1.col2 = other_table.col2
FROM
    Table1
INNER JOIN
    other_table
ON
    Table1.id = other_table.id
0
 
LVL 13

Expert Comment

by:Ashok
ID: 37763711
UPDATE Nop_Product AS A
INNER JOIN TempOne AS B ON A.F1=B.F1
JOIN Nop_ProductVariant C ON B.title_id = C.title_id
  SET A.F1 = 1, A.F2 = 2
WHERE C.SKU =101222
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 37763855
Somehting like this perhaps:
UPDATE  n
SET     SEName2 = t.Brand,
        MetaTitle2 = Category		-- Not sure what table Category belongs to.
FROM    Nop_Product n
        INNER JOIN Nop_ProductVariant v ON n.ProductID = v.ProductID
        INNER JOIN TempOne t ON v.SKU = t.SKU

Open in new window

0
 
LVL 16

Author Closing Comment

by:MikeMCSD
ID: 37763902
nicely done ac,  . .  . thanks
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TDE for SQL Web Edition 1 42
Restore a log backup compressed 3 18
SQL Query 20 25
Need SQL Query improved for multiple column joins 2 15
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

710 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