Marmachine Posted May 30, 2011 Share Posted May 30, 2011 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 https://forums.phpfreaks.com/topic/237841-copy-row-from-table-1-into-table-2-reset-id-use-autoincrement/ Share on other sites More sharing options...
Muddy_Funster Posted May 30, 2011 Share Posted May 30, 2011 yeah - stop using select * INSERT INTO <table1> (field2, field3, field4...) SELECT (field2, filed3, filed4... FROM <table2> WHERE field1 = [value]) Link to comment https://forums.phpfreaks.com/topic/237841-copy-row-from-table-1-into-table-2-reset-id-use-autoincrement/#findComment-1222216 Share on other sites More sharing options...
Marmachine Posted May 30, 2011 Author Share Posted May 30, 2011 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 https://forums.phpfreaks.com/topic/237841-copy-row-from-table-1-into-table-2-reset-id-use-autoincrement/#findComment-1222220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.