Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

setting the id to not 1 for data joining...

deezzerdeezzer Member Posts: 1
hi.

i'm trying to append data from one table to another.

Imagine two tables. table A has no id, table B does. Table B has 10 entries in it. Table A has 20 entries.

i'd like to add the data in table A to table B, and for the entries in table A to start incrementing at 11, 12 13 (where table B leaves off in it's unique ids)

the syntax would probably look something like...INSERT INTO tableB id=11, (auto_increment) SELECT * FROM tableA..but i'm not sure..

can someone help? thank you.

Comments

  • quotientquotient Member Posts: 62
    Simplest method:

    Say you have that table:
    [code]
    id field1 field2 field3
    == ====== ====== ======
    1 TEXT VALUE BLOB
    2 TEXT VALUE BLOB
    3 TEXT VALUE BLOB
    4 TEXT VALUE BLOB
    [/code]

    First, make sure the 'id' column is auto_increment. Simply do a simple INSERT...SELECT statement:
    [code]INSERT INTO tableB SELECT field1,field2,field3 FROM tableA[/code]

    Should do the trick.

    F

    : hi.
    :
    : i'm trying to append data from one table to another.
    :
    : Imagine two tables. table A has no id, table B does. Table B has 10 entries in it. Table A has 20 entries.
    :
    : i'd like to add the data in table A to table B, and for the entries in table A to start incrementing at 11, 12 13 (where table B leaves off in it's unique ids)
    :
    : the syntax would probably look something like...INSERT INTO tableB id=11, (auto_increment) SELECT * FROM tableA..but i'm not sure..
    :
    : can someone help? thank you.
    :

Sign In or Register to comment.