dreamMyDream2014 2014-05-09 10:22
浏览 15
已采纳

来自不同表的上一年记录

I have store my student database in a table student. When the session is over I move the database to different table alumni. And I have form for querying those students where I put session/Year selection. For current session I have no problem querying the database. But for querying previous years student database from alumni in the same form I have no idea how I would query. I just used the following code but this code is limited to one previous year and do not cover the whole past years. Please help me as I am new to this.

 $regd=$_GET['regd'];
 $yr=$_GET['Year'];

 $pyr=date("Y")-1;//Current Year minus one equals to Previous year.
 if($yr==$pyr){
 $query_pic = "SELECT * FROM alumni WHERE regd='$regd' and Year='$yr'";
 }else{
  $query_pic = "SELECT * FROM student WHERE regd='$regd' and Year='$yr'";
 }

Now I want to dynamically select all the past years student database which were stored in alumni table.

  • 写回答

2条回答 默认 最新

  • doushangxianq07480 2014-05-09 10:30
    关注

    Try this:

     $regd=$_GET['regd'];
     $yr=$_GET['Year'];
    
     $pyr=date("Y")-1;//Current Year minus one equals to Previous year.
     if($yr==$pyr){
     $query_pic = "SELECT * FROM alumni WHERE regd='$regd' and year(Year)<='$yr'";
     }else{
      $query_pic = "SELECT * FROM student WHERE regd='$regd' and Year='$yr'";
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大