MySQL Forums
Forum List  »  Stored Procedures

Multipline lines insert in a table with Autoincrement field
Posted by: Omer Ntumba
Date: March 02, 2013 12:54AM

Hello,
I noticed something in mysql while making a multiple lines insert in a table that has an autoincrement field
My command is this one
insert into contracts (reference, customer_id, service_id, amount)
select @ref, customer_id, @service, @amount from customer
where customer_type = 'IND'
This command insert a specific service in the contracts table for all individual customers.
The contract table has a field named contract_id which is an autoincrement field.
Let's say the last contract_id inserted is 4 and from the new command, there are 10 more lines.
Logically, the increment should start at 5 and ends at 14.
Unfornatunately, it started at 14 (add 10 lines in the select line) and ends at 23. and breaking the sequence
Is there someone who faced this problem?
Looking forward to hearing from you

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.