-
Inserting data from one table to another
Hi, I have two tables in a data base and i'm inserting the data from one into the other...no probs. What i was wondering is, in table1 i have an column of ID numbers. In the table2 i have a matching set of ID numbers. There are 5 PersonID numbers in table one and 10 in table two, the same 5 numbers as in table1 but each ID has a duplicate with different data in the two rows.
SAMPLE:
INSERT
INTO Table1 (PersonID, level1, Level2, Level3, Level4)
SELECT PersonID,level1, Level2, Level3, Level4
FROM Table2
When i insert the data into table1 it leaves the first 5 rows of data as null and then populates the table with all the data from table two. Is there anyway of preventing these first 5 columns from remaining empty....
I hope that makes sense
-
Do you have sample data in both tables?
-
Yeah in table1 there are five rows of data for the personID column each one containing a unique number, however columns level1 to level4 have no data. In table 2 there are ten rows of data for each column, however in the personID column
has duplicates, for example:
Table2
PersonID Level1 Level2 ...............etc
B569 (Data here) (Data here)
B569 (Data here) (Data here)
H351 (Data here) (Data here)
H351 (Data here) (Data here)
Each (Data here) holds unique data
-
What do you try to get? Want to copy table2 to table1? Then just delete first 5 rows that have no data in leveln columns.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|