Results 1 to 4 of 4

Thread: Inserting data from one table to another

  1. #1
    Join Date
    Aug 2007
    Posts
    4

    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

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Do you have sample data in both tables?

  3. #3
    Join Date
    Aug 2007
    Posts
    4
    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

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    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
  •