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?

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.