我正在尝试使用 PHP 在 MySQL 中选择年份:
session_start();
$school_id = $_SESSION['school_id'];
$section_id = $_POST['section_id'];
$today = date("Y");
$select_grades_deped = "SELECT *
FROM deped_grade_archive
WHERE school_id='$school_id'
AND section_id='$section_id'
AND year(submission_date) ='$today' ";
$query_check_grades= mysql_query($select_grades_deped) or die (mysql_error());
$check_count = mysql_num_rows($query_check_grades);
if($check_count == 0){
$return['checked'] = "0";
}
else{
$return['checked'] = "1";
}
echo json_encode($return);
但不幸的是,当我尝试以下操作时:
SELECT year( submission_date )
FROM deped_grade_archive
WHERE school_id = '$school_id'
AND section_id = '$section_id'
它从我的表中返回零值。我将数据类型更改为数据类型,submission_date
因为date
它是varchar
以前的但仍然没有用。请帮助各位。