Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update a table 1

Status
Not open for further replies.

bjm027

MIS
Mar 7, 2003
59
US
I have two tables and they are related by a common ID. tbl_1 has a unique ID and tbl_2 is related to tbl_1 through this ID.

I have a field in tbl_2 that is missing values that are stored in tbl_1. I want to update those values in tbl_2 to match that of tbl_1.

Hope this was clear. I tried and update statement using an inner join and I am not to sure that MS SQL supports inner joins or my syntax was wrong.

Any help on how the update statement would turn out to be.

Thanks in advance...
 
Please post what you wrote. SQL Server certainly supports inner joins.

Questions about posting. See faq183-874
 
This is what I tried

------CODE--------
UPDATE tbl_1 INNER JOIN tbl_2 ON tbl_1.ID=tbl_2.ID
SET tbl_1.Company = tbl_2.Company;
-----------------
 
Books ONline said:
UPDATE titles
SET ytd_sales = titles.ytd_sales + sales.qty
FROM titles, sales
WHERE titles.title_id = sales.title_id


Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top