简体   繁体   English

如何更新表格行的多个值

[英]How to update table row multiple values

I need some help I can not update all the values stored in column views, I want to add random numbers. 我需要一些帮助,我无法更新存储在列视图中的所有值,我想添加随机数。

I have over 300 videos and I want to update all the views records. 我有300多个视频,我想更新所有的观看记录。

A small example here what does not work, only if I update a single row this is working. 这里有个小例子,只有当我更新一行时,它才行得通。

UPDATE videos SET views VALUES ( 1234, 2234, 3455, 4564 ) WHERE user_id = 3;

What exactly is wrong here i try to find solutions on Google but unfortunately nothing found to help me. 我在这里尝试在Google上找到解决方案的地方到底出了什么问题,但是很遗憾,没有找到任何解决方法。

Thank you so much!! 非常感谢!!

[Example Table] ( https://i.stack.imgur.com/bvsww.png ) [示例表]( https://i.stack.imgur.com/bvsww.png

I want to add random numbers 我想添加随机数

You could use: 您可以使用:

UPDATE videos 
SET views  = FLOOR(1 + RAND() *1000)
WHERE user_id = 3;

db<>fiddle demo db <> fiddle演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM