Jump to content

Copy row from table 1 into table 2, reset ID (use autoincrement)


Marmachine

Recommended Posts

Hi folks,

 

I have a table that contains concept-invoices, now when a user says it's okay, i copy the specific row from table concepts into a table with invoices using the following query:

 

insert into INVOICES (select * from CONCEPTS where ID = 17)

 

so far, so good... but, i want to use autoincrement as the ID value in the target table... is there a way?

yeah - stop using select *

 

INSERT INTO <table1> (field2, field3, field4...) SELECT (field2, filed3, filed4... FROM <table2> WHERE field1 = [value])

 

You know how lazy us programmers can be :-) not wanting to name all fields all the time... but if this is the only way...?

 

I was just trying this .... '0' AS ID .... however, no success yet!

 

Maybe i better name the fields like you say huh!? Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.