leetcode刷题记录-数据库篇

** 1.连接考察点:**

  1. inner join: 结果保留匹配的
  2. left join: 结果为左边全部的
  3. right join: 结果为右边全部的
  4. full join: 结果为左右所有的

** 2.查询薪水第二高,空可以返回**

select ifnull(
   ( SELECT distinct 
   Salary from Employee 
    order by Salary desc limit 1,1 ),null)
     as SecondHighestSalary`

** 3.查找重复的电子邮箱**

select distinct a.Email from Person a ,Person b where a.Email = b.Email and a.id!=b.id 
#或
select Email from Person group by Email having count(*)>1


你可能感兴趣的:(leetcode刷题)