List:General Discussion« Previous MessageNext Message »
From:Brian Dunning Date:October 11 2005 4:00pm
Subject:Re: Append one table to another?
View as plain text  
> INSERT into tbl1 SELECT * FROM tbl2

Thanks to both of you, but this is not working. Since one of the  
fields is a primary key that's duplicated in both tables (both tables  
have records numbered 1, 2, 3...), it won't allow the duplicate  
entries. Fortunately I do not need those primary key values to be  
preserved - it's OK to insert the new records with auto-increment  
values where the target table left off. So I tried:

insert into target_table select `field1`,`field2` from original_table;

and I listed all but the auto-increment field. This doesn't work  
either, it just says to check my syntax, but I can't see a problem.  
Any ideas?
Thread
Append one table to another?Brian Dunning11 Oct
  • Re: Append one table to another?Paul DuBois11 Oct
  • Re: Append one table to another?Peter Brawley11 Oct
    • Re: Append one table to another?Brian Dunning11 Oct
      • Re: Append one table to another?Paul DuBois11 Oct
  • Re: Append one table to another?Jose Miguel PĂ©rez11 Oct
    • Re: Append one table to another?Brian Dunning11 Oct