在刷LeetCode的时候遇到的SQL题目
627.Swap Salary
Given a table salary
, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single update query and no intermediate temp table.
For example:
| id | name | sex | salary |
|----|------|-----|--------|
| 1 | A | m | 2500 |
| 2 | B | f | 1500 |
| 3 | C | m | 5500 |
| 4 | D | f | 500 |
After running your query, the above salary table should have the following rows:
| id | name | sex | salary |
|----|------|-----|--------|
| 1 | A | f | 2500 |
| 2 | B | m | 1500 |
| 3 | C | f | 5500 |
| 4 | D | m | 500 |
大概就是要求交换表中sex列的性别
一开始想着用update salary set sex = f when sex = m再用个AND,后来一想这样执行的结果应该是错的、
然后就偷看了solution,才知道还有when case语句,所以记录一下
update salary set sex =
case sex
when 'm' then 'f'
else 'm'
end;
大概意思就是when m,then就设置为f,else都设置为m
最新评论
搭好后 防火墙就自动关了,请问有没有办法让防火墙开起的情况下,比如添加端口,让梯子能用?
感谢,一次搞定
作者写的就是只能命令行访问,在GUI界面 注册表查询依旧没有走代理。
这个跟bandwagon的一样吗 也是能用v2ray吗
一步步来的,就是不行。
如果不需要了,如何恢复呢?