[PHP] Mass mySQL update...

2004-12-17 Thread Russell P Jones
So I populated a mySQL database but forgot to create random ids for each
record.

I have used phpmyadmin to add a varchar(15) column named id at the end
of the database for each record, but now am wondering if there is an easy
way to get random ID's into each of these...

The column values for many of the entries are not unique, so I couldnt
just loop through saying where term = $row[term] set id= rand(1, 9)

any other ideas? Any way to refer to a particular row without matching
values?

Russ

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



Re: [PHP] Mass mySQL update...

2004-12-17 Thread Jason Wong
On Saturday 18 December 2004 00:39, Russell P Jones wrote:

 I have used phpmyadmin to add a varchar(15) column named id at the end
 of the database for each record, but now am wondering if there is an easy
 way to get random ID's into each of these...

Why? What are these random ID's used for?

 The column values for many of the entries are not unique, so I couldnt
 just loop through saying where term = $row[term] set id= rand(1, 9)

 any other ideas? Any way to refer to a particular row without matching
 values?

UPDATE without a WHERE clause (or with WHERE 1) will update all rows.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
BOFH Excuse #308:

CD-ROM server needs recalibration
*/

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



Re: [PHP] Mass mySQL update...

2004-12-17 Thread John Nichel
Russell P Jones wrote:
So I populated a mySQL database but forgot to create random ids for each
record.
I have used phpmyadmin to add a varchar(15) column named id at the end
of the database for each record, but now am wondering if there is an easy
way to get random ID's into each of these...
The column values for many of the entries are not unique, so I couldnt
just loop through saying where term = $row[term] set id= rand(1, 9)
any other ideas? Any way to refer to a particular row without matching
values?
Russ
http://lists.mysql.com/
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Mass mySQL update...

2004-12-17 Thread Ligaya Turmelle
if you don't mind it being an int - try something like...
ALTER TABLE table
ADD ID INT NOT NULL INTEGER UNIQUE AUTO_INCREMENT,
ADD PRIMARY KEY (ID);
Reference:
http://dev.mysql.com/doc/mysql/en/ALTER_TABLE.html
Respectfully,
Ligaya Turmelle
---
Life is a game... so have fun.
---
www.PHPCommunity.org
Open Source, Open Community
Visit for more information or to join the movement

Russell P Jones wrote:
So I populated a mySQL database but forgot to create random ids for each
record.
I have used phpmyadmin to add a varchar(15) column named id at the end
of the database for each record, but now am wondering if there is an easy
way to get random ID's into each of these...
The column values for many of the entries are not unique, so I couldnt
just loop through saying where term = $row[term] set id= rand(1, 9)
any other ideas? Any way to refer to a particular row without matching
values?
Russ

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