sql - MySQL: update all rows with random numbers from list -


i need run sql query picks random number list , updates specific column it.

list of numbers:

(101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122)

rand table: (structure)

id  rand    type 1    0       false 2    0       true 3    0       false 4    0       true 5    0       true 

i need pick random number list , update "rand" column,

try this:

 update `rand` set `rand` = (select val (     select 101 val     union select 102     union select 103     union select 104     union select 105     union select 106     union select 107     union select 108     union select 109     union select 110     union select 111     union select 112     union select 113     union select 114     union select 115     union select 116     union select 118     union select 119     union select 120     union select 121     union select 122 ) vals order rand() limit 1) 

it update rand column random value list @ each execution

if list of numbers predefined table can this:

 update `rand` set `rand` = (select `number` `number_table` order rand() limit 1) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -