Re: inserting an auto incemented column in table already created
| From: | Marek Kilimajer | Date: | Sat, 30 Apr 2005 16:50:32 +0000 |
| Subject: | Re: inserting an auto incemented column in table already created | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214268@lists.php.net to get a copy of this message | ||
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);