mysql select数据输出[[null]] 或[]问题

 

{"headers": {"Employee": ["Id", "Salary"]}, "rows": {"Employee": [[1, 100]]}}

输出:{"headers":["SecondHighestSalary"],"values":[]}

预期:{"headers":["SecondHighestSalary"],"values":[[null]]}

 

 

一、使用“IFNULL”

 

SELECT
    IFNULL(
      (SELECT DISTINCT Salary
       FROM Employee
       ORDER BY Salary DESC
        LIMIT 1 OFFSET 1) ,
    NULL) AS SecondHighestSalary

 

二、

SELECT
    (
SELECT DISTINCT
            Salary
        FROM
            Employee
        ORDER BY Salary DESC
        LIMIT 1 OFFSET 1) AS SecondHighestSalary
 

 

 

你可能感兴趣的:(mysql)