728x90
반응형
leetcode.com/problems/swap-salary/
Swap Salary - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
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.
UPDATE salary
SET sex = IF(sex='m', 'f', 'm')
UPDATE Syntax
UPDATE TABLE
SET COL1=VAL1, COL2=VAL2
WHERE CONDITION
IF Statement Syntax
IF(condition, true, false)
728x90
반응형
'Record1' 카테고리의 다른 글
[LeetCode] 888. Fair Candy Swap [Python] math (0) | 2020.11.23 |
---|---|
[LeetCode] 409. Longest Palindrome [Python] 해시 (0) | 2020.11.09 |
[LeetCode] 442. Find All Duplicates in an Array [Python] 배열 (0) | 2020.11.08 |
[LeetCode] 1436. Destination City [Python] 해시셋 (0) | 2020.11.08 |
[LeetCode] 187. Repeated DNA Sequences [Python] 해시셋 (0) | 2020.11.07 |