update with random value
-
Hi, I have a field called stock_value and I want to update the value with either 10 or 20 so t should list the records in random way then update the first as 10, second as 20, thrid as 10, fourth as 20 etc until end of records.. How can I do this? Thanks, Jassim
-
Hi, I have a field called stock_value and I want to update the value with either 10 or 20 so t should list the records in random way then update the first as 10, second as 20, thrid as 10, fourth as 20 etc until end of records.. How can I do this? Thanks, Jassim
You don't say what database you're using, so I'll assume it's SQL-Server. Random ordering you can get by making a variation of this query:
SELECT * FROM table ORDER BY NEWID()
Then you can use the
CASE
andMOD
operators to update every second row.Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions