数据库共有两上表:学员和班级是有关联关系
第一个:学员列表:
数据库表里:ID:1 学员性名:XXX 班级ID:55
            ID:X 学员性名:XXX 班级ID:XX
            ID:X 学员性名:XXX 班级ID:XX第二个表:班级列表:
ID:55 入学日期:2010.08.1 毕业日期:2010.10.01
ID:xx 入学日期:xxx 毕业日期:xxx
ID:xx 入学日期:xxx 毕业日期:xxx注明:两个表里面都有很多条数据。问题:我要在页面显示所有学员,条件是:毕业一年以上的学员除外。用什么方法除了毕来一年以上的学员外,其如的都显示到页面上???数据库:mysql
各们高手可以的话可以写的长细点吗??~~~谢谢

解决方案 »

  1.   

    select 学员姓名 from 学员列表 where 班级ID not in select id from 班级列表 where 毕业日期<2010.10.01
      

  2.   

    select × from 学员列表 where 班级ID not in (select id from 班级列表 where 毕业日期<(1年))
    这个1年必须是你计算出来的(当前时间-毕业时间)
      

  3.   

    select b.* from 班级列表 a left join 学员列表 b on a.班级ID = b.班级ID where year(CURRENT_DATE ())-year(a.毕业时间)>=1 
    关键还是当前的时间减去毕业时间的年差
      

  4.   

    select id from student where classid not in (select id from classinfo where '2010-09-30'<(getdate()-'2010-09-30'));
    是这样吗??
    student表
    classinfo 表
      

  5.   

    select * from classinfo left join student id=classid where year(CURRENT_DATE())-year('2010-09-30 00:00:00')>=1
    是这样写吗??
    student表
    classinfo 表
      

  6.   

    LZ 你发这个问题 要那么多吗?? 再 给你 发一次
    SELECT  b.xname,b.cid,c.rux,c.bye from AB b,AC c where TIMESTAMPDIFF(year,c.bye,'2010-9-8 11:11:11')<1 and b.cid=c.id
      

  7.   

    select 学员姓名 from 学员列表 where 班级ID not in (select id from 班级列表 where datediff(yyyy,2010.10.01-毕业日期)>1)
    后面的算年份得根据你的数据库中毕业日期的类型来决定。方法没错。
      

  8.   


    (year,c.bye,'2010-9-8 11:11:11')这句是不是写成(year,c.bye,毕业时间)
    还有c.bye是什么意思
      

  9.   

    select * from student,classinfo where TIMESTAMPDIFF(year,endclsdate,getDATE())<1 and classid=classinfo.idmysql里能不能用getDATE()来获取系统当前时间的??
      

  10.   

    (year,c.bye,'2010-9-8 11:11:11')这句是不是写成(year,c.bye,毕业时间)
    还有c.bye是什么意思(year,c.bye,'2010-9-8 11:11:11') 写成(year,毕业时间,当前系统时间)
      

  11.   

    Timestamp curTime = new Timestamp(System.currentTimeMillis()); 可以这样获取
      

  12.   

    如果 是MYsql 也可以用 now()获取系统当期时间