如何在单个查询中更新所有工资值 [英] how to update the all salary value in single query

查看:95
本文介绍了如何在单个查询中更新所有工资值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表格如下





Id姓名薪水



1 A 2000

2 B 3000

3 C 4000



我想要所有的全部薪水得到一半工资的名字。



我的例外输出如下



Id姓名工资



1 A 1000

2 B 1500

3 C 2000



为什么我可以使用单个sql查询编写。

解决方案

尝试:

 更新 MyTable  SET 薪水=薪水/  2  


Table as follows


Id Name Salary

1 A 2000
2 B 3000
3 C 4000

I want to all the salary of the all the name to get half of the salary.

My excepted output as follows

Id Name Salary

1 A 1000
2 B 1500
3 C 2000

for that how can i write using single sql query.

解决方案

Try:

UPDATE MyTable SET Salary = Salary / 2


这篇关于如何在单个查询中更新所有工资值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆