https://leetcode.com/problems/swap-salary/description/ 用  set keyWord = Case depentedWord when haha then baba else lala end 最后需要end # Write your MySQL query statement below update salary set sex = case sex when 'm' then 'f' else 'm' end;…
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 query and no intermediate temp table. For example: | id | name | sex | sala…
题目标签: 题目给了我们一个 工资表格,让我们把 男女性别对换. 这里可以利用IF, IF(condition, value_if_true, value_if_false). 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 s…
627. Swap Salary SQL Schema 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 query and no intermediate temp table. For examp…
原因是:oracle数据库更新数据后需要commit,不然会堵塞,就会卡住 那么每次调用executeUpdate()完后,数据库要自动commit才可以. 我的基类加了一下,注意红色字体部分代码: //增删改 public int executeUpdate(String sql,Object[] params){ int update = 0; try { pstm = connection.prepareStatement(sql); for(int i=0;i<params.length…
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 query and no intermediate temp table. For example: | id | name | sex | sala…
184. Department Highest Salary The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--…
1.只批量插入: insert into WXPAY_ACCOUNT(id ,out_trade_no ,transaction_id)select SEQ_WXPAY_ACCOUNT.nextval id,a.* FROM ( SELECT#{wxpayAccount.outTradeNo ,jdbcType=VARCHAR},#{wxpayAccount.transactionId ,jdbcType=VARCHAR}FROM dual ) a 2.批量插入(存在不插入) merge int…
MySQL的IF既可以作为表达式用,也可在存储过程中作为流程控制语句使用,如下是做为表达式使用: IF表达式 IF(expr1,expr2,expr3) 如果 expr1 是TRUE (expr1 <> 0 and expr1 <> NULL),则 IF()的返回值为expr2; 否则返回值则为 expr3.IF() 的返回值为数字值或字符串值,具体情况视其所在语境而定. SELECT IF(sva=1,"男","女") AS s FROM…
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Jo…