mysqli两个列日期之间的一个日期

时间:2015-04-17 13:01:05

标签: date mysqli between

我正在尝试从数据库中获取行数,可能是:

$query = mysqli_query($con, "SELECT * FROM table WHERE '2015-03-01' IS BETWEEN column_1 and column_2  ");

if (mysqli_num_rows($query) < 1) {
    echo "nothing found !";
} else {
    echo "numrow found !";
}

1 个答案:

答案 0 :(得分:0)

阅读手册mysql between syntax

介于两者之间是错误的语法:

BETWEEN运算符选择范围内的值。值可以是数字,文本或日期。

    $query = mysqli_query($con, "SELECT * FROM table WHERE '2015-03-01' BETWEEN column_1 and column_2");

    if (mysqli_num_rows($query) < 1) {
            echo "nothing found !";
    }else{
     echo "numrow found !";
    }