如何交换表中行的值 [英] How to Interchange Values of Rows in A Table

查看:69
本文介绍了如何交换表中行的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在表格(Emp)中有一列如下





性别

M

M

M

F

F

M

F



现在我想将值从'M'更改为'F'和'F'更改为'M '。

我怎么能在一个查询中得到这个...

请帮助我...

解决方案

< blockquote>您好,



查找以下查询





 更新 yourTable 
set 性别=
case 性别
何时 ' F' 然后 ' M'
' M' 然后 ' F'
end ;







希望这会对你有帮助。


Hi,
I have a column in table (Emp) like below


Gender
M
M
M
F
F
M
F

Now i want to change the values from 'M' to 'F' and 'F' to 'M'.
How can i get this in a single query..
Please help me...

解决方案

Hi,

Find query below


update yourTable
set Gender =
  case Gender
    when 'F' then 'M'
    when 'M' then 'F'
  end;




Hope this will help you.


这篇关于如何交换表中行的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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