List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:July 15 1999 6:54pm
Subject:Re: Random Ordering
View as plain text  
Ying Zhang wrote:
> 
> I have a table of articles like so:
> 
> articleid   int not null auto_increment
> sequence    int
> name        varchar(50)
> 
> And data like so:
> 
> articleid      name          sequence
> ---------      ----          --------
> 1              Cooking       1
> 2              Shopping      2
> 3              TV            3
> 4              Computers     4
> (etc.)
> 
> What I'd like to be able to do is be able to view this data and
> rearrange the sequence using the least amount of UPDATE and SELECT
> statements.  With the current structure viewing the data in sequence
> requires a simple SELECT .... ORDER BY sequence, but I would need
> multiple updates to rearrange the sequence.
> 
> To minimize the UPDATE's, I've thought about keeping the sequence in a
> column of another table (eg. "1,2,3,4") but that would make SELECT's
> really bad.
> 
> Does any one have any suggestions?
> 
> Ying

Hi Ying

How about using the RAND() function in the UPDATE like:
UPDATE articles SET sequence=RAND();

And then selecting normally by 'sequence'?

Tschau
Christian

PS: Sorry for the late answer, I was on vacation.

Thread
Random OrderingYing Zhang29 Jun
  • Re: Random OrderingChristian Mack15 Jul