字段中有一个生日字段(birthday),是日期类型,里面的数据都是2004-11-15格式的,如果我想查找年龄在18-25岁的人如何写SQL,谢谢!

解决方案 »

  1.   

    你用select * from table where birthday >  DataTime.now.year.addyears(-18)and birthday<DAtaTime.now.year.addyears(-25)试试看看
      

  2.   

    select * from table where birthday>='1980-11-15'and birthday<='1986-11-15'
      

  3.   

    select * from table 
    where DATEADD(year, 18, birthday) >  getdate() and DATEADD(year, 25, birthday)<getdate()
      

  4.   

    select * from table where birthday between '1980-11-15' and '1986-11-15'
      

  5.   

    select * from table1 where (year(now)-year(ddd))>=18 and  (year(now)-year(ddd))<=25test in office access
      

  6.   

    select * from 表名 where between (year(getdate())-year(birthday)) >=18 and (year(getdate()) -year(birthday)) <= 25;你看看可对啊!!!!