leetcode收获

left outer join table on 
distinct唯一值,distinct必须放在开头
limit 1,1 返回第二值 
group by having count()>1 累加
SELECT  *  FROM  user  WHERE  name like CONCAT('%',#{name},'%') 
DATEDIFF() 函数返回两个日期之间的时间。
UNION 用于合并两个或多个 SELECT 语句的结果集,并消去表中任何重复行
mod(N,M)该函数返回N除以M后的余数
update salary set sex=case sex when 'm' then 'f' else 'm' end交换性别
创建函数:create function(,,) returns 参数类型 Begin 
return(sql); end          返回第N高的薪水  :
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
      set N=N-1;
  RETURN (
      # Write your MySQL query statement below.      
    select ( select distinct Salary as getNthHighestSalary from Employee order by Salary desc
      limit N,1 ) As getNthHighestSalary
  );
END 
原文地址:https://www.cnblogs.com/DIVEY/p/10232334.html