Gossamer Forum
Home : General : Databases and SQL :

Randomize MySQL Rows

Quote Reply
Randomize MySQL Rows
Hello,

I am trying to reorder the rows in a MySQL database. A typical row withing the DB looks like
ID,CATEGORY,URL

There are a few hundred URLs in each category, each with a unique ID. Surfers will see the links in order according to their ID number. I'd like to assign the URL to another ID number within the same category. Is this possible using MySQL commands or will I have to do some kind of crazy array manipulation? Any ideas would be most appreciated.
Quote Reply
Re: [BennyHill] Randomize MySQL Rows In reply to
Why do you need to renumber the rows? If your end result is to simply reorder the output, why don't you just do an "order by rand"?

--Philip
Links 2.0 moderator
Quote Reply
Re: [sponge] Randomize MySQL Rows In reply to
It's not quite that simple. If it were, don't you think I would have done that? Anyway, is there an easy way to do what I am after? I did finally write something that works, but it has to execute a few queries and a couple of inserts to get the job done, quite ugly. There has to be a better way.
Quote Reply
Re: [BennyHill] Randomize MySQL Rows In reply to
What's the purpose of changing the IDs? Protecting your links from harvesting?