-2

我想从表中选择最大日期和最小日期。使用表格

$datemax=$_POST['maxdate'];
$datemin=$_POST['mindate'];
    ("select * from demande inner join gestionnaire on gestionnaire.idgab = demande.idgab  where demande.idgab='$idgabsess' order by demande.dateincidnt")

我想从 dateincidnt 列中选择 ($datemax) ------> (datemin)

4

2 回答 2

2

您可以使用MySQL between子句。

SELECT * FROM table WHERE date BETWEEN $start_date AND $end_date

在您的代码中

select * from table where dateincidnt between $datemax and datemin
于 2013-03-09T09:24:47.093 回答
2

使用BETWEEN运算符

$sql = "select * from demande
        inner join gestionnaire on gestionnaire.idgab = demande.idgab
        where demande.idgab='$idgabsess'
              and dateincidnt between $datemin and $datemax
        order by demande.dateincidnt";
于 2013-03-09T09:24:56.190 回答