HI everyone, I have this problem.
Example I have table like this:
ID is auto_increment field.
ID | Name
1 A
2 B
3 C
4 D
I now, I insert a record with specified id = 10 , for example, with name is "K"
So, My table now look like this:
ID | Name
1 A
2 B
3 C
4 D
10 H
And I know, value of auto_increment now is 10, if i insert a record without specified id value, value of auto_increment will be 11.
Problem is:
I want to insert record into my table, with next auto_increment id will be 5, and so on, next is 6,7,8,9 (don't need to be in order) like this:
ID | Name
1 A
2 B
3 C
4 D
10 H
5 X
6 F
7 P
8 K
9 L
At this time, when i insert a record, auto_increment value will be 11. And now, my table is:
ID | Name
1 A
2 B
3 C
4 D
10 H
5 X
6 F
7 P
8 K
9 L
11 O
Can I do this, I try to get the value before inserting the record with id = 10 into var x, when i insert this ( id = 10), then i try to reset auto_increment with value of x, but this isn't correct.
Can anyone me help ? With Php/Mysql code ?.
Thank you a lot.