KingLove KingLove - 1 year ago 148
MySQL Question

Query update fails to update number

I found out that I should use floor and rand when I want to update a column with a random number from 1 to 3. Found it on another question on this site.
However, it does not seem to work for me all though I followed the instructions given in the other post.

I've been troubleshooting for the past hour and a half and I badly need help.
my code is:

$result = $mysqli->query('UPDATE users_extended SET field3 = FLOOR( 1 + RAND( ) *3 ');

Do you know where my fail is?

Thank you on behalf

Answer Source

close parenthes

$result = $mysqli->query('UPDATE users_extended SET field3 = FLOOR( 1 + RAND( ) *3 )');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download