我想在一個表里找出,不等於'aaaa,bbb,ccc,dddd,eee,'等這些的紀錄
如何操作?
我使用not "aaaa,bbb,ccc,dddd,eee"
<>"aaaa,bbb,ccc,dddd,eee"
和not in(aaaa,bbb,ccc,dddd,eee)
都不管用.

解决方案 »

  1.   

    如果这样的字串有很多,建议把这些字串单独建一个表存放,如A表,字段B,SQL查询语句就简单了,也高效:
    select tablename.* from tablename left join A on tablename.fieldname=A.B where A.B is null and 其他条件
      

  2.   

    如果这样的字串有很多,建议把这些字串单独建一个表存放,如A表,字段B,SQL查询语句就简单了,也高效:
    select tablename.* from tablename left join A on tablename.fieldname=A.B where A.B is null and 其他条件
      

  3.   

    这样写:
    not in('aaaa','bbb','ccc','dddd','eee')
      

  4.   

    最好是将aaaa,bbb,ccc,dddd,eee存在一个表里 table_name
    然后这样:select * from test  where name not in ( select col_name from table_name)
      

  5.   

    select * from table where name not in('aaaa','bbb','ccc','dddd','eee')
      

  6.   

    not in('aaaa','bbb','ccc','dddd','eee')
      

  7.   

    select * from table where table.filed1 not in ('aaaa','bbb','ccc','dddd','eee')或者:select * from table where table.filed1<>'aaaa' and table.filed1<>'bbb' and table.filed1<>'ccc' and table.filed1<>'dddd' and table.filed1<>'eee'不过第1种(也就是二楼的方法)较简洁。
      

  8.   

    在access里這些not in(table.字段名)都不能用,倒是不出錯,只是執行的結果沒有反映,就跟沒有增加這個查詢條件一樣,不知道是為甚ㄇ?