我在一个网站上工作,它要求我只在一个表中显示具体的课程,并按年份进行具体说明。
以下是我表格中的一些细节:
桌上学生
stdid、stdcoursedesc、accessdate
12211,飞机维修许可证计划?欧洲广告标准联盟第66部分,2018-3-6
12212,飞机维修许可证计划?欧洲广告标准联盟第66部分,2015-8-6
12213,飞机维修技术(制造)文凭,2017-3-1
12214,工商管理硕士(创业),2018-1-16
12215,飞机维修许可证计划?欧洲广告标准联盟第66部分,2015-10-1
12216,飞机维修许可证计划?欧洲广告标准联盟第66部分,2016-12-10
12217,哲学博士(制造),2016-5-14
我只管理代码,直到这个,但当然它只显示课程。
SELECT CONCAT(`stdCourseDesc`, ', ', `accessDate`) AS byYear FROM student WHERE `stdCourseDesc` = 'Aircraft Maintenance License Program ? EASA Part 66'
我试过但失败了。
SELECT CONCAT(stdCourseDesc, ', ', accessDate) AS byYear FROM student where `stdCourseDesc` = 'Aircraft Maintenance License Program ? EASA Part 66', YEAR(`accessDate`)=2015
我将使用这个代码来显示输出
$conn = new mysqli ('localhost', 'root', '', 'dashboard');
$aircraftyear2015 = $conn ->query ("SELECT CONCAT(`stdCourseDesc`, ', ',
`accessDate`) AS byYear FROM student WHERE `stdCourseDesc` = 'Aircraft
Maintenance License Program ? EASA Part 66'");
$aircraftyear2016 = $conn ->query ("SELECT CONCAT(`stdCourseDesc`, ', ',
`accessDate`) AS byYear FROM student WHERE `stdCourseDesc` = 'Aircraft
Maintenance License Program ? EASA Part 66'");
$aircraftyear2017 = $conn ->query ("SELECT CONCAT(`stdCourseDesc`, ', ',
`accessDate`) AS byYear FROM student WHERE `stdCourseDesc` = 'Aircraft
Maintenance License Program ? EASA Part 66'");
$aircraftyear2018 = $conn ->query ("SELECT CONCAT(`stdCourseDesc`, ', ',
`accessDate`) AS byYear FROM student WHERE `stdCourseDesc` = 'Aircraft
Maintenance License Program ? EASA Part 66'");
$tot_aircraftyear2015 = mysqli_num_rows($aircraftyear2016);
$tot_aircraftyear2016 = mysqli_num_rows($aircraftyear2017);
$tot_aircraftyear2017 = mysqli_num_rows($aircraftyear2016);
$tot_aircraftyear2018 = mysqli_num_rows($aircraftyear2017);
<?php echo $tot_aircraftyear2015; ?>
<?php echo $tot_aircraftyear2016; ?>
<?php echo $tot_aircraftyear2017; ?>
<?php echo $tot_aircraftyear2018; ?>
我要如何在一个mysql表中按特定年份过滤特定课程?
我的代码可以用来显示数据吗?先谢谢你
1条答案
按热度按时间agxfikkp1#
可能是语法问题,请尝试以下操作: