[英]Select row if conditions is greater than 100
I have two table in my database, - user
- videos
我的数据库中有两个表格,- user
- videos
In my user
table I have a column called balance
and in my videos
I have I column called views
. 在user
表中,我有一个列为balance
,在videos
我有一个列为views
。
I want if the views in my video reach 1000 my balance will update by plus one in my user table any ideas. 我希望视频中的观看次数达到1000时,我的余额将在用户表中加上1个更新任何提示。
SELECT view
FROM videos
If views=1000
UPDATE user SET balance=balance+1 WHERE user
id = user id
You can use an update-join statement: 您可以使用update-join语句:
UPDATE user u
JOIN views v ON u.userid = v.userid
SET balance = balance + 1
WHERE v.views >= 1000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.