0

I am trying to add column to a table in mysql with increment numbers, no matter if some of the rows would be deleted. For example:

id  name   surname  question/column
1   Peter  Peterson       1
5   Mike   Nikolson       2
11  Selena Selenson       3

The point is to get in every moment increment values, cause I need a list with numbers. Hope that is no big deal for much experiences database brains.

2

1 Answer 1

1

If you are trying to add an enumerated column to a result set, then use variables:

select jb, (@rn := @rn + 1) as seqnum
from justbrackets jb cross join
      (select @rn := 0) vars
order by id;
Sign up to request clarification or add additional context in comments.

1 Comment

I am trying to add column. If it is possible of course?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.