2 Star 10 Fork 2

CG国斌 / myleetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
_627.sql 971 Bytes
一键复制 编辑 原始数据 按行查看 历史
Charies Gavin 提交于 2020-02-06 12:44 . 初始化 myleetcode 项目
-- 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 statement and no intermediate temp table.
--
-- Note that you must write a single update statement, DO NOT write any select statement for this problem.
--
-- Example:
--
-- | id | name | sex | salary |
-- |----|------|-----|--------|
-- | 1 | A | m | 2500 |
-- | 2 | B | f | 1500 |
-- | 3 | C | m | 5500 |
-- | 4 | D | f | 500 |
--
-- After running your update statement, 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 |
-- # Write your MySQL query statement below
update salary set sex = CHAR(ASCII('f') ^ ASCII('m') ^ ASCII(sex));
Java
1
https://gitee.com/guobinhit/myleetcode.git
git@gitee.com:guobinhit/myleetcode.git
guobinhit
myleetcode
myleetcode
master

搜索帮助