Solved

Join 3 tables for an Update

Posted on 2012-03-25
4
406 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
4 Comments
 
LVL 7

Expert Comment

by:Lalit Chandra
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
nicely done ac,  . .  . thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now