0

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

5
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by eantz
0

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

0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.