组合两个表
-- 解法1
select p.FirstName ,p.LastName,a.City,a.State from Person p left join Address a on (a.personId = p.personId);
-- 解法2
SELECT p.FirstName,p.LastName,a.City,a.State FROM Person p LEFT JOIN Address a USING(PersonId );
select max(Salary) as 'SecondHighestSalary' FROM Employee where salary < (SELECT MAX(Salary) FROM Employee);
- limit是mysql的语法select * from table limit m,n其中m是指记录开始的index,从0开始,表示第一条记录n是指从第m+1条开始,取n条。
select ifnull((SELECT distinct
Salary
FROM
Employee
order by Salary desc
limit 1,1),null) AS SecondHighestSalary