当前位置:网站首页>LeetCode: 627. 变更性别
LeetCode: 627. 变更性别
2022-07-22 09:11:00 【东西方集大成者】
原题:https://leetcode-cn.com/problems/swap-salary/
个人解法:
update salary set sex = if(sex='m', 'f', 'm');
官方解法:
使 用 c a s e − w h e n 使用case- when 使用case−when
UPDATE salary
SET sex =
CASE sex
WHEN 'm' THEN 'f'
ELSE 'm'
END;
使用ascii码
一加一减,结合ascii()函数和char()函数
update salary set sex = char(ascii('m') + ascii('f') - ascii(sex));
小结:
在数据库中,非黑即白,非白即灰的问题一般都是使用IF语句
或Case When语句
边栏推荐
- Visual studio debugging shortcut key
- 2、 Notes
- App移動端測試【6】應用程序(apk)包管理與activity
- 【STM32】STM32 SDIO SD卡读写测试(一)-- SD卡硬件设计和软件移植
- 03.单一职责原则(Simple Responsibility Pinciple)
- OSI模型,TCP/IP模型
- 使用工厂的方法创建对象
- [SDIO] sd2.0 protocol analysis summary (III) -- Introduction to SD card related commands
- 【Nordic】nRF52810 OTA升级(二)–DFU如何使用
- [SDIO] SDIO, SD card, FatFs file system related article index
猜你喜欢
debug glance(by quqi99)
[audio] analysis and summary of PCM audio data transmitted by I2S (I)
【Nordic】nRF52810 OTA升级(二)–DFU如何使用
Fabric. JS centered element
[STM32] STM32 SDIO SD card read / write test (II) -- SD_ Power on phase of init
App mobile End test [6] application (APK) package Management and Activity
批量查分爬虫
04.接口隔离原则(Interface Segregation Principle)
【FatFs】基于STM32 SD卡移植FatFs文件系统
Is it really necessary to define VO, Bo, Po, do, dto?
随机推荐
使用工厂的方法创建对象
Applet implementation list and details page
Go 语言学习:Go 语言之旅(五)
Wechat official account web page authorization ----- redirect_ The URI domain name is inconsistent with the background configuration, and the error code is 10003
no input file specified 解决方案
[audio] analysis and summary of PCM audio data transmitted by I2S (I)
Add the GD Library under centos7.5, and then the MySQL expansion library. There is no problem without the configuration of MySQL expansion. There is no MySQL expansion in phpinfo
构造函数
[audio] transplant wm8978 audio codec driver based on STM32 I2S
debug glance(by quqi99)
【STM32】STM32 SDIO SD卡读写测试(一)-- SD卡硬件设计和软件移植
2、 Notes
Visual studio debugging shortcut key
DOM添加
Go 语言学习:Go 语言之旅(三)
【STM32】STM32 SDIO SD卡读写测试(三)-- SD_Init之Init Card阶段
charm zaza functional test (by quqi99)
C language simple TCP server program
[SDIO] SDIO, SD card, FatFs file system related article index
3、 Generics