是否可以从sql查询返回2个值?

时间:2021-06-11 09:10:18

is it possible to return 2 values from this?

是否可以从中返回2个值?

I want that HAVING clause have maximum of two.

我希望HAVING子句最多有两个。

$sql = mysql_query("
SELECT *
FROM 
    `Bill`
WHERE
    ID_Number='12345'
HAVING 
    max(`Pay_Date`)
ORDER BY
    `Pay_Date`
 DESC LIMIT 2");

1 个解决方案

#1


0  

you can order the result by pay_date instead.

您可以通过pay_date来订购结果。

$sql = mysql_query("
SELECT *
FROM 
    `Bill`
WHERE
    ID_Number='12345'
ORDER BY
    `Pay_Date`
 DESC LIMIT 2");

This should work because you will be ordering the results by pay_date in desc. order. So the latest two dates will be displayed.

这应该有效,因为您将在desc中按pay_date命令结果。订购。因此将显示最新的两个日期。

#1


0  

you can order the result by pay_date instead.

您可以通过pay_date来订购结果。

$sql = mysql_query("
SELECT *
FROM 
    `Bill`
WHERE
    ID_Number='12345'
ORDER BY
    `Pay_Date`
 DESC LIMIT 2");

This should work because you will be ordering the results by pay_date in desc. order. So the latest two dates will be displayed.

这应该有效,因为您将在desc中按pay_date命令结果。订购。因此将显示最新的两个日期。