Hi,
I have the following table:
Name Row(number)
Nico 1
Marko 2
Peter 3
Joy 4
Kimi 5

I delete Nico and Joy:
Marko 2
Peter 3
Kimi 5

And how to make a table would look as follows:
Marko 1
Peter 2
Kimi 3

How to automatically re-arranged in a row of seats.

I hope to understand what I wanted to ask. Sorry for the English language

Recommended Answers

All 4 Replies

you need to update the primary key when you delete the record

example

delete from number1 where name in ('Nico ','Joy')

then

UPDATE number1 SET number= number- 1 where name ='Marko';
 UPDATE number1 SET number= number- 1 where name ='Peter ';
 UPDATE number1 SET number= number- 2 where name ='Kimi';

automatically , sorry i don't know

You probably could run an update after each delete that would look something like:

UPDATE number1 SET number = number-1 where number > *deleted name id num*

and just set the *deleted name id num* to the id of the one you just deleted.

Why do you want to change the auto increment column?
I think Column with auto increment feature will be primary key. so it doesn't need to be changed..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.