S
S
Sergey Ivanov2015-10-21 14:50:54
MySQL
Sergey Ivanov, 2015-10-21 14:50:54

How to randomly sort and change a field?

Tell me. There is a table. It contains many different drinks. How to make them sort randomly and change the gender value

id | position | name
1 | 1 | test
2| 2| test2
3| 3| test3


id | position | name
1 | 1 | test
2| 3| test3
3| 4| test2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Kostin, 2015-10-21
@Writerim

SET @incr = 0;

UPDATE myTable
SET position = @incr :[email protected] + 1
ORDER BY RAND();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question