我有一张这样的桌子
a_count b_count total_count(a_count+b_count)
2 3
5 1
4 7
5 0
这是我的表我需要使用单个查询更新总计数字段.我该如何编写这种查询?我需要像这样的输出
a_count b_count total_count(a_count+b_count)
2 3 5
5 1 6
4 7 11
5 0 5
要更新表中这些字段的值:
UPDATE mytable SET total_count = a_count + b_count
Run Code Online (Sandbox Code Playgroud)
要从表中获取这些字段:
SELECT a_count, b_count, total_count FROM mytable
Run Code Online (Sandbox Code Playgroud)
要获取没有该total_count列的字段:
SELECT a_count, b_count, (a_count+b_count) AS total_count FROM mytable
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88 次 |
| 最近记录: |