473,325 Members | 2,872 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,325 software developers and data experts.

Query to copy rows in a table with a change in two columns

3
I need to copy a single row in a table (TeamMember) multiple times but with changes in two columns (iFDA_ID and iMemberIndex). iMemberIndex will simply need to be incremented each time and the value for iFDA_ID comes from another table (FDA). What do you think is the best way to do this?

Note: I have removed some columns from these tables to make it easier to follow.



The TeamMember table:

iIDVerID (PK)
iMemberIndex (PK)
iFDA_ID
szName


The FDA table

iIDVerID (PK)
iFDA (PK)
szName



Example:
I have a row in the TeamMember table with the following values:
iIDVerID = 26092
iMemberIndex = 1
iFDA_ID = NULL
szName = 'test1'

I also have 3 rows in the FDA table with the following values:

Row 1
iIDVerID = 26092
iFDA = 1001
szName = 'Wave 1 - Concept'

Row 2
iIDVerID = 26092
iFDA = 1002
szName = 'Wave 1 - Concept'

Row 3
iIDVerID = 26092
iFDA = 2001
szName = 'Wave 1 - Concept'



Now, I want to insert a new row into the TeamMember for each row in the FDA table where the iIDVerID values match. The value for TeamMember.iFDA_ID should come from FDA.iFDA (1001, 1002, and 2001). The value for iMemberIndex is just incremented (2, 3, 4, etc.). The values for all the other columns in TeamMember should not change (szName = 'test1', etc.).

Note that iIDVerID and iMemberIndex combine to make the primary key of the TeamMember table. This probably makes it a little more difficult to make a join or subquery because iMemberIndex must be unique.



Thanks in advance for any help.
Aug 27 '07 #1
0 1363

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

Similar topics

5
by: jason | last post by:
I could sure use some conceptualization and query help with a Page Watch System I am building in Access 2000 and Asp. I need to cycle through databae and generate a compiliation query email that...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
3
by: b_naick | last post by:
I have 2 tables: - Users, with fields id and fullName - Accounts, with accntID, userID, accntName, Active I need to write a query which lists all the users, along with the number of accounts...
7
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
24
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
3
by: Bill Hutchison | last post by:
I have a query that returns different results (3508 rows for snapshot, 6288 for dynaset) and that is the only thing I change to get the different results. When I try to make a table from the...
3
by: nagmvs | last post by:
Hi to all I have one table with 6 columns and 20 rows.I want to sort each and every column when i click the column name in the table. for sorting i create one more page.when i click the column...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.