List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 11 2005 4:03pm
Subject:Re: Append one table to another?
View as plain text  
At 9:00 -0700 10/11/05, Brian Dunning wrote:
>>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?

The manual is your friend:

http://dev.mysql.com/doc/mysql/en/insert-select.html

-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
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