leetcoed the database

A combination of two tables

The same applies to the entire inner join Table A and Table B of the additional properties: jion: the connector

       An outer connector: left join attribute applies to all of the left and right plus Table A and Table B attributes matching the query conditions, i.e., the left primary table the table. Similarly, right join right table the primary table.

      select FirstName,LastName,City,State
      from Person left outer join Address
      on  Person.PersonID = Address.PersonID

Second, the second-highest salary

IFNULL (value1, value2)
      . 1, value1 if not empty, return the result value1.
      2, if value1 is empty, the result returns value2.
Back Limit x how many data limit x, y + 1 starts from the section X, are y returned.
distinct data de-duplication, then de-duplication of data in descending order, i.e., beginning with the limit 1,1 second, a data fetch, also taken to the second high salary.


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

 Note: ifnull Do not forget the value2, value1 parentheses sql statement too long

 

Guess you like

Origin www.cnblogs.com/xiaojingjingzhuanshu/p/11567314.html