我正在尝试选择行,如果给定的日期仅在表中的两个日期之间,则可以选择。
在课程表中,我有开始日期和结束日期。
如果可能,我还需要在查询内部进行条件判断。
$coursneededdate >= startdate AND $coursneededdate <= enddate
这是我的代码,非常感谢您的帮助。
$coursneededdate = '2020-08-27';
$sql = "SELECT * FROM curriculum where ".$coursneededdate." between 'startdate' and 'enddate'";
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo $row["curriculum_id"];
}
}
SELECT * FROM curriculum where '".$coursneededdate."' between 'startdate' and 'enddate'
如果仍然没有结果,请检查日期是否有5年后的课程。 - chris85