I hope i'm explaining this properly... but i'm trying to update a column in a table with 30k rows with a repeated sequence.

I've populated entire columns before with random numbers using:

UPDATE locations SET template = CAST((RAND() \* 4)+1 AS UNSIGNED);

Which gave:

* 2
* 4
* 5
* 1
* 3

etc. in a random fashion throughout the 30k rows...

I would like to enter a query that can produce a repeated sequence like:

* 1
* 2
* 3
* 4
* 5
* 1
* 2
* 3
* 4
* 5

across all 30k rows.

I've been looking into loops and auto increments but can't get it to work.

Any help much appreciated :)