条件语句里
取时间在两个时间段里的记录
2010-10-01 大于datefrom小于 2010-10-10

2010-12-01 大于datefrom小于 2010-12-10

解决方案 »

  1.   


    where (datefrom < '2010-10-10' and datefrom > '2010-10-01')
          or 
          (datefrom < '2010-12-10' and datefrom > '2010-12-01')
      

  2.   

    where (datefrom  < '2010-10-10' and datefrom > '2010-10-01')
           or 
          (datefrom < '2010-12-10' and datefrom > '2010-12-01')同意,然后稍微注意一下 如果 datefrom 为 字符类型而不是 日期类型的话 要 cast 转换一下类型
      

  3.   

    where datefrom between '2010-10-01' and '2010-10-10'
          or 
          datefrom between '2010-12-01' and '2010-12-10'不过这样感觉效率有点低,呵呵。
      

  4.   

    ---写法一,这样效率会低一些
    where datefrom between '2010-10-01' and '2010-10-10'
      or  
      datefrom between '2010-12-01' and '2010-12-10'
    --方法二 ,用or效率不会太高
    where dateform >'2010-10-01' and datefrom <'2010-10-10'
    or
    dateform>'2010-12-01' and datefrom<'2010-12-10'
      

  5.   

    ---写法一,这样效率会低一些
    where (datefrom between '2010-10-01' and '2010-10-10')
      or  
      (datefrom between '2010-12-01' and '2010-12-10')
    --方法二 ,用or效率不会太高
    where (dateform >'2010-10-01' and datefrom <'2010-10-10')
    or
    (dateform>'2010-12-01' and datefrom<'2010-12-10')
      

  6.   

    where (datefrom < '2010-10-10' and datefrom > '2010-10-01')
          or 
          (datefrom < '2010-12-10' and datefrom > '2010-12-01')
      

  7.   

    where (datefrom < '2010-10-10' and datefrom > '2010-10-01')
          or 
          (datefrom < '2010-12-10' and datefrom > '2010-12-01')
      

  8.   

    select * from table where (datefrom between '2010-10-1' and '2010-10-10') or (datefrom between '2010-12-1' and '2010-12-10')
      

  9.   

    where (datefrom < '2010-10-10' and datefrom > '2010-10-01')
      or  
      (datefrom < '2010-12-10' and datefrom > '2010-12-01')
      

  10.   


    where (datefrom between '2010-10-01' and '2010-10-10')
          or 
          (datefrom < '2010-12-01' and '2010-12-10')
      

  11.   


    select * from tablename where (datefrom between '2010-10-10' and '2010-10-01')
      

  12.   

    where (datefrom between '2010-10-01' and '2010-10-10')
          or 
          (datefrom < '2010-12-01' and '2010-12-10')
      

  13.   

    between and 
    <条件> 
    or
      

  14.   

    select * from tablename where (datefrom < '2010-10-10' and datefrom > '2010-10-01')
    union all 
    select * from tablename where (datefrom < '2010-12-10' and datefrom > '2010-12-01')
    效率高点
      

  15.   

    select * from tablename where (datefrom < '2010-10-10' and datefrom > '2010-10-01')
    union all 
    select * from tablename where (datefrom < '2010-12-10' and datefrom > '2010-12-01')
    用这个,绝对没错的。速度快高效率