[英]Subtract two Columns from a Specific Row
I have a table similar to the one below: 我有一张类似于以下表格:
ID
Vote_Up
Vote_Down
Vote_Total 1 3 1 2 2 1 3 -2 3 23 7 16 4 5 1 4 5 7 5 2 6 2 2 0 7 9 1 8
How do i Come up with the Vote_Total? 如何提出Vote_Total?
尝试这个:
update mytable set vote_total = vote_up - vote_down
If you already have the column,and want to update @ssamuel's answer will guide you. 如果您已经有此专栏,并且想更新@ssamuel的答案,将会为您提供指导。 If you do not have the Vote_Down column, and wanted to select it as a column in query.
如果您没有Vote_Down列,并希望将其选择为查询中的列。 This would be the select query :
这将是选择查询:
SELECT ID , Vote_Up , Vote_Down , ( Vote_Up - Vote_Down)
as Vote_Total from myVotesTable
Assumed : Vote_Up and Vote_Down are integer or varchar fields with numeric values. 假定:Vote_Up和Vote_Down是具有数字值的整数或varchar字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.