Giter Club home page Giter Club logo

leetcode's Introduction

LeetCode

leetcode's People

Contributors

hupochuan avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

leetcode's Issues

Swap Salary

这个题也是MySQL查询语句的,忘得差不多了,在这做一个总结。
方法一:
Update salary
set sex=(
CASE
WHEN sex = 'f' THEN 'm'
WHEN sex = 'm' THEN 'f'
ELSE sex
END
)
也可以这么写:
Update salary
set sex=(
CASE sex
WHEN 'f' THEN 'm'
WHEN 'm' THEN 'f'
ELSE sex
END
)
方法二:
UPDATE salary SET sex = IF(sex = 'm', 'f', 'm')
注:IF(expr1,expr2,expr3)
如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2; 否则返回值则为 expr3。IF() 的返回值为数字值或字符串值,具体情况视其所在语境而定。
方法三:
update salary set sex = CHAR(ASCII('f') ^ ASCII('m') ^ ASCII(sex));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.