Reputation: 41
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.
Upvotes: 0
Views: 83
Reputation: 1270773
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;
Upvotes: 1