1UPDATEsalary2SETsex=CHAR(ASCII('f')^ASCII('m')^ASCII(sex)); 当然上面的如果不好理解,还可以选用if 的形式 1UPDATEsalary2SETsex=IF(sex='m','f','m'); 或者使用when的形式 1UPDATEsalary2SETsex=(CASEWHENsex='m'3THEN'f'4ELSE'm'5END) 最后一种来自LeetCode 一个叫做kevin36的大神。 这...
Java Solution: Runtime: 135 ms, faster than 94.04% Memory Usage: N/A 完成日期:07/02/2019 关键点:IF(condition,value_if_true,value_if_false) # Write your MySQL query statement belowUPDATEsalarySETsex=IF(sex='m','f','m'); 参考资料:LeetCode Discuss LeetCode 题目列表 -LeetCode Questions...
https://leetcode.com/problems/swap-salary/ Given a tablesalary, 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...
LeetCode 627. Swap Salary 题目要求:将数据库表中的字段sex反转,f--->m,m--->f 思路:当有三个数,其中两者相等,要得出另外一个数时可用异或 m^m^f = f; f^m^f = m. 在这道题中,可将m与f转为ASCII码,再进行异或 1UPDATEtable2SETsex=CHAR(ASCII(sex)^ASCII('m')^ASCII('f') ); 若不...
leetcode-627. Swap Salary Given a tablesalary, 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....
➤GitHub地址:https://github.com/strengthen/LeetCode ➤原文地址:https://www.cnblogs.com/strengthen/p/10472837.html ➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。 ➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
leetcode 627. Swap Salary 数据库带判断的更新操作 https://leetcode.com/problems/swap-salary/description/ 用set keyWord = Case depentedWord when haha then baba else lala end 最后需要end View Code
Swap Salary Solution: 分类:Sql 标签:LeetCode算法题 好文要顶关注我收藏该文微信分享 mabianbian2006 粉丝-1关注 -74 +加关注 0 0 升级成为会员 «冒泡排序 »Array Partition I posted on2019-02-21 10:30mabianbian2006阅读(71) 评论(0)编辑...
leetcode 627. Swap Salary 数据库带判断的更新操作 https://leetcode.com/problems/swap-salary/description/ 用set keyWord = Case depentedWord when haha then baba else lala end 最后需要end View Code