Update Statment Help using JOINS?

Okay so I know how to select data from tables using Joins but how do I update whilst using this principle.

Eg.  I have 3 tables, 1: Stock, 2: StockToRecords, & 3: Records

I could do this in a select
SELECT records.recid from records
INNER JOIN StockToRecords ON Records.RecID = StockToRecords.RecID
INNER JOIN Stock ON StockToRecords.Partno = Stock.Partno
where Stock.Partno = 'banana'

So I can select based on the Stock table but how using this relation as above would I update a column in records using a where clause from stock?

Thanks in advance,

Andrew
andrewmilnerAsked:
Who is Participating?
 
Aneesh RetnakaranDatabase AdministratorCommented:
UPDATE R
SET urColumn = newValue

from records r
INNER JOIN StockToRecords ON r.RecID = StockToRecords.RecID
INNER JOIN Stock ON StockToRecords.Partno = Stock.Partno
where Stock.Partno = 'banana'
0
 
andrewmilnerAuthor Commented:
Spot On!!!

That's fantastic.  Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.