If you want to "combine two tables" by copying rows from TableB into TableA, and TableA has an autoincrementing primary key, there is no need to reference the PK column in the SQL statement:
insert into TableA(address, weight) select address, weight from TableB The approach above does indeed "bypass the primary key conflict" because it leaves it up to TableA to assign the PK value upon insert. Now, I don't know what inflexible "program" you are using that doesn't give you control over which columns you want to select. Maybe your "program" will let you create a view on TableB? create view MyView as select address, weight from TableB and then you could insert into TableA(address, weight) select address, weight from MyView Regards Tim Romano On 3/15/2010 9:32 AM, dravid11 wrote: > Well the situation is that i am merging data of one table in data of another > table using a program > so it is going to add all values by it self .I am not actually using insert > query in that case to select values to add. > > > There is another scenario , what if inserting a data and i want to bypass > the primary key conflict and just update rest of the values. > > again i am combing two tables together so it should take all columns . > > > > Tim Romano wrote: > >> If all you want to do is to insert a new row, do not mention the primary >> key column name in the insert statement: >> >> INSERT INTO temp (address, weight) >> values( "blah blah", 100) >> >> The autoincrementing primary key will be autoincremented. >> >> Regards >> Tim Romano >> >> >> On 3/15/2010 9:15 AM, dravid11 wrote: >> >>> Hello ! >>> I have been trying to search for this solutions for days,yet did not find >>> the solution. >>> >>> >>> I want to write an insert query on a table. When there is a conflicting >>> primary key >>> then it should increment the primary key and insert the row . >>> >>> For example i want to run this query >>> INSERT INTO temp VALUES("1","112","112"); >>> >>> Here first column is auto increment primary Key. >>> This query will add the record(20,112,112) in the table >>> Now when i run the query as >>> >>> INSERT INTO temp VALUES("1","100","100"); >>> >>> I want the result as (2,100,100) >>> >>> But it give unique constraint error. >>> How can i do that ,i.e, duplicate primary key comes in a table insert the >>> new record and change the primary key of the new record. >>> >>> I have used this query but did not work >>> >>> insert or replace INTO temp (tempID,Address,Weight) >>> VALUES(new."tempID",new."Address",new."Weight") ; >>> SELECT RAISE(IGNORE); >>> END >>> >>> >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> >> >> > > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.733 / Virus Database: 271.1.1/2748 - Release Date: 03/15/10 > 03:33:00 > > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users