> Hi,
> 
> I have a mysql table:
> +-----------+------------------+------+-----+
> | Field     | Type             | Null | Key |
> +-----------+------------------+------+-----+
> | sessionid | int(10) unsigned |      | PRI |
> | username  | char(20)         |      | MUL |
> | start     | int(10) unsigned |      | MUL |
> | stop      | int(10) unsigned |      | MUL |
> | ipaddress | char(15)         | YES  |     |
> +-----------+------------------+------+-----+
> 
> sessionid is a unique key.
> 
> Is there a way to change the values of sessionid such that
> the values will be numbered from 1 and increments by 1?
> 
> ie, if the numbers were "1,20,22,25,40,45,47....."
> the new data will be "1,2,3,4,5,6,7,8,9....." ?
 
Though I don't understand why you need to do this, here's
a way:

ALTER the table to include an AUTO_INCREMENT column.
This will automatically add an incrementing counter
to existing rows. Then UPDATE the sessionID field,
setting it = to the value of the AUTO_INCREMENT field.

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to