$data = Db::table("exam_situation")
->alias("es")
->join("exam_plan ep", "ep.ep_id=" . $posts["ep_id"])//exam_plan.ep_id==form传过来选择的ep_id
->join("student stu", "stu.stu_num=es.usernum")//exam_situation.usernum==student.stu_num
->field("title,study_year,semester,in_year,major,classname,stu_num,name,grade")
->where([
["es.grade", $char, $grade_num],
["es.ep_id", "=", $posts["ep_id"]],//exam_situation.ep_id==form传过来选择的ep_id
["es.ac_id", "=", session("ac_id")]
])
->fetchSql(true)
->select();
echo $data;
输出的语句是:
SELECT `title`,`study_year`,`semester`,`in_year`,`major`,`classname`,`stu_num`,`name`,`grade`
FROM `exam_situation` `es` INNER JOIN `exam_plan` `ep` ON `ep`.`ep_id`=`28`
INNER JOIN `student` `stu` ON `stu`.`stu_num`=`es`.`usernum`
WHERE `es`.`grade` <= '59' AND `es`.`ep_id` = '28' AND `es`.`ac_id` = '9'
注意看第一个28那里是反引号,就很奇怪,导致数据库也查不出来。谁能帮我回答一下为什么