两个表,
 A:
 人员(ID,name)
 
 B:
 请假 (ID,人员ID,起始时间,结束时间)
 
 我想查找今天没有请假的人员名单,请赐教

解决方案 »

  1.   

    select * from a inner join b on a.id=b.id
    where not (b.结束时间>=curdate() or 起始时间>=curdate())
      

  2.   

    or
    select * from a inner join b on a.id=b.人员id
    where b.结束时间<curdate() and 起始时间<curdate()
      

  3.   

    or
    select * from a inner join b on a.id=b.人员id
    where not (curdate() between b.起始时间  and b.结束时间)
      

  4.   

    select *
    from 人员
    where not exists (select 1 from 请假 where 人员ID=人员.ID and curdate between 起始时间 and 结束时间)
      

  5.   

    select * from a
    where not exists (select 1 from 请假 where 人员ID=a.ID and curdate() between 起始时间 and 结束时间)
      

  6.   


    select * from  人员 where id not in (select 人员ID from 请假 where day(起始时间)=day(now());
      

  7.   

    select * from a where begindate>gedate or enddate <gedate left join b where a.id=b.id;
      

  8.   

    A:
     人员(ID,name)
      
     B:
     请假 (ID,人员ID,起始时间,结束时间)===>
    select 
    from a 
    where not exists(select * from b where a.id=人员id and day(起始时间)=day(now()))