August 20, 2008 at 2:47 am
Hello clever peeps
Does anyone know how to update using a joined set of tables
I have two tables with a common primary key. Table compound has the following fields
compound_id (int primary key)
compound (varchar(100)
hazard_info (varchar(200)
Table hazard has the following fields
compound_id (int primary key matches other table)
hazard_phrase (varchar(200)
I would like to update the compound table and insert the hazard_phrase from the hazard table into the hazard_info of the compound table.
I am using SQL Server 8
Thanks in advance
August 20, 2008 at 4:01 am
See BOL ---> UPDATE statement ---> Using the UPDATE statement with information from another table
August 20, 2008 at 4:03 am
UPDATE c SET hazard_info = h.hazard_phrase
FROM compound c
INNER JOIN hazard h on h.compound_id = c.compound_id
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 20, 2008 at 4:05 am
Thank you
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply