You are here: Re: [PHP] inserting an auto incemented column in table already created « PHP « IT news, forums, messages
Re: [PHP] inserting an auto incemented column in table already created

Posted by Marek Kilimajer on 04/30/05 19:50

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);

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация