Re: inserting an auto incemented column in table already created

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ross Hulford wrote:
Hi,

I have a table with 15 columns or so that has been inherited from an older db and am trying to insert an auto increment column (in mysql) without having to number it manually. This is fine when I add new colums via a form but the old entries have a null value

Alternatively It has been converted from Excel soif anyone knows how to do it that way that would help.I never use Excel so have no clue about it.


R.



$id = 1;

do {
mysql_query('update table_name set id = ' . $id++ . ' where id is null limit 1');
} while(mysql_affected_rows() > 0);


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux