例如 我要查询表 tableA中字段 colA不在 10到20的区间 并且 不在30到40的区间 并且不在60 到70的区间。这三个区间都是没有交集的。求一条语句 谢谢了 
具体是这样的 我要查询的表中的一个字段值 有很多错误信息 我是想通过循环把每条错误的的 记录给它找出来。
select colA from tableA where not((colA between 10 and 20) and (colA between 30 and 40) and (colA between 60 and 70))  这样写 不报错 但是我执行了 之后发现数据不对 。

解决方案 »

  1.   

    select colA from tableA where colA <10 or (cola>20 and cola<30 ) or (cola>40 and cola<60) or cola>70
      

  2.   


    select colA
      from tableA
     where not ((colA between 10 and 20) or (colA between 30 and 40) or
            (colA between 60 and 70))
      

  3.   

    你的应该要这么写:select colA from tableA where not((colA between 10 and 20) or (colA between 30 and 40) or (colA between 60 and 70))
      

  4.   


    select colA from tableA where colA <10 or cola>20 and cola<30  or cola>40 and cola<60 or cola>70between and 好像不会用索引,最好少用