473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Updating multiple Tables with one UPDATE Statement

I would like to be able to update any number of Tables in a Database by referencing another Table that has the data that needs to be updated using INNER JOINS.

Tbl1, Tbl2, Tbl3.
TempTbl.

The fileds in Tb;1- Tbl3 that are to be updated would be ID.
TempTbl would have 2 fields: OldID, NewID

Expand|Select|Wrap|Line Numbers
  1.  UPDATE Tbl1, Tbl2, Tbl3
  2.        ((INNER JOIN TempTbl ON Tbl1.ID = TempTlb.OldID)
  3.        (INNER JOIN TempTbl ON Tbl2.ID = TempTlb.OldID))
  4.         INNER JOIN TempTbl ON Tbl3.ID = TempTlb.OldID
  5.        SET Tbl1.ID = TempTbl.NewID,Tbl2.ID =
  6.           TempTbl.NewID,Tbl3.ID = TempTbl.NewID;
This didn't work for me. The idea is to be able to do it for an arbitrary number of tables.

Thank you.
Feb 3 '16 #1
1 849
NeoPa
32,556 Expert Mod 16PB
Father Christmas being real would be nice too.

You don't really ask a question, but if I were interested in updating multiple tables concurrently via a single UPDATE SQL command I'd start by getting and updatable SELECT statement and then converting that to an UPDATE. If that enabled updating of fields from more than one of the underlying tables then I'd count myself lucky.
Feb 3 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Falco Vermeer | last post by:
Hi, I tried to use the following query to update a value in one table with a value from another table: UPDATE tbl1 SET col1 = tbl2.col2 FROM tbl1, tbl2 WHERE tbl1. = tbl2.
8
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
1
by: JLM | last post by:
I'm sure this has been addressed before, but I haven't found it yet. I have a form that I want to use to update multiple tables (with same/similar info). I can append a single table without much...
1
by: Justin | last post by:
What is the best/easiest way to update multiple tables at a time? Can you recommend any tutorials? Thanks, Justin.
1
by: evandela | last post by:
Hi all... this is one part of ASP.net that i just dont understand... and GOD knows, i am trying. I have 2 tables, the first one called country and the second called product I create a datagrid...
1
by: Rob Dob | last post by:
Hi, I have both a Customer and a Orders Table, the key field is CustomerID. I also have a DataGridView that uses a BindingSource created using a join between the Customers table and the Orders...
13
by: srinivas gandrath | last post by:
Hi all, I am having trouble to writing stored procedure to insert and update the 2 tables in sql server 2005. Here is my problem. I have 2 tables with following columns. TableName:BENEFIT_PDF...
3
by: phillikl | last post by:
Good day, Having a total brain fart on this and need some help. Access 2007 2 Tables Table1: Director (200 records) Field1: Name Field2: phone
4
Claus Mygind
by: Claus Mygind | last post by:
I am wondering what is the best solution to this problem. The platform PHP 5.3 MySQL 5.0.27 MyISAM table engine Windows xP I have a reference key in multiple tables which links those...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.