473,434 Members | 1,672 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,434 software developers and data experts.

update and insert help new to sql

I have a table (table1) with a bunch of records say 50.

this table has a code that is repeated in one column for the 50 records, example code is 123456

I want to update/change code 123456 to a new code based on a list of distinct codes stored in a second table (table2) but evaluate and update one at a time, example below

example: the first distinct code from table2 is code 456789, I want to take that code and update code 123456 in table1 to 456789 in table1 and then append these records from table1 to a 3rd table (table3)

then repeat the process for each distinct code in table2,

next code
the second distinct code from table2 is code 666666, I want to take that code and update code 456789 in table1 to 666666 in table1 and then append these records from table1 to a 3rd table (table3)

and repeat, repeat, repeat


I know you have to use a variable and loop but not that sure how to accomplish.

thanks
May 14 '10 #1
4 1169
ck9663
2,878 Expert 2GB
Is your code in table1 unique?

~~ CK
May 17 '10 #2
@ck9663
no it repeats for every record
May 17 '10 #3
ck9663
2,878 Expert 2GB
So how are the two tables related? Could you post some sample data and tell us how it should look like after the update?

~~ CK
May 18 '10 #4
thanks but I think I am all set
May 18 '10 #5

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

Similar topics

5
by: jn | last post by:
I have a page that shows info from MySQL. It is for an online education site. It uses different classes arranged in a hierarchy. Each lesson is roughly laid out like this: Lesson |-Intro |...
2
by: Jenny | last post by:
Hi! I wonder how to use conditions in the inserted table(in a insert/update) trigger? The inserted table contain all the rows that have been updated or inserted (for an update/insert trigger),...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
1
by: Lisa | last post by:
I have an asp.net website with an Access Database that works great on my local server, but when I migrated to our production server, none of my sql processes works (i.e update, insert, delete) Does...
1
by: luna | last post by:
trying to create an update/insert button basically if the record exists in the database i want to do an update if it doesnt exist i want to create a new record using insert all using the same...
0
by: Daniel | last post by:
update/insert with microsoft.xml.xquery(.net2.0beta) can anyone provide an example of how to update/insert with microsoft.xml.xquery?
0
by: dev | last post by:
Hi Everyone, I'm a little confused with the .NET 2.0 BindingSource for WinForms. Is it possible to update, insert or delete database items through the BindingSource with a Typed data object as its...
6
by: kareemaffan | last post by:
Hello Everyone I want to insert values into MS Access database through VB.NET in Visual Studio 2005 . I have used the following code which is not working. Private Sub Button2_Click(ByVal sender...
1
by: sridhar4554 | last post by:
How to give a grant like select,update,insert on a single table i had tried with the command grant eg:GRANT SELECT,INSERT,UPDATE ON DTS_OUTBOX_QUEUE TO sanpapps@dap1 IDENTIFIED BY 'disable';...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.