July 12th, 2000, 04:26 PM
Join Date: Oct 1999
Location: Annapolis, Maryland US
Time spent in forums: < 1 sec
Reputation Power: 15
There is another way and you could even do it from an sql batch file, but would you want to?
The 5 easy pieces...
> alter table table_name modify id int not null;
> alter table table_name drop primary key;
> alter table table_name modify id int;
> update table_name set id=NULL;
> alter table table_name modify id int not null auto_increment primary key;
I believe that should do it, but my suggestion would be to read all the ids from the table into an array and then randomly choose one from that array, so you know it exists.
Better yet, try
> select id, content, content*0+RAND() as rand_col from table_name order by rand_col limit 1;
[This message has been edited by Kyuzo (edited July 12, 2000).]