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
> 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?
How about using the RAND() function in the UPDATE like:
UPDATE articles SET sequence=RAND();
And then selecting normally by 'sequence'?
PS: Sorry for the late answer, I was on vacation.
|• Random Ordering||Ying Zhang||29 Jun|
| • Re: Random Ordering||Christian Mack||15 Jul|