在sql语句里我要实现不存在name=xxx的记录,这个怎么写的,求指教了,xxx是个字符串

解决方案 »

  1.   

    select * from t where name<>'xxx' ?
      

  2.   

    那就简单点说吧,现在有一个表A,有字段1和2,我要从A里去数据,但是取出来的数据中1=XXX的我不要,这个怎么写的
      

  3.   

    select * from A where col1!='XXX';
      

  4.   

    <>貌似不行,不能用在字符串上,我试了下不行的
      

  5.   

    A表:
           1           2
          aa          001
          bb          001
          cc          001
          dd          002
    现在就是说去2=001的数据但是1=aa的数据我不要,只显示bb和cc
      

  6.   

    你的SQL语句是什么,不可能不行啊?!mysql> select * from a;
    +------+------+
    | f1   | f2   |
    +------+------+
    | aa   | 001  |
    | bb   | 001  |
    | cc   | 001  |
    | dd   | 002  |
    +------+------+
    4 rows in set (0.00 sec)mysql>
    mysql> select * from a where f1 != 'aa';
    +------+------+
    | f1   | f2   |
    +------+------+
    | bb   | 001  |
    | cc   | 001  |
    | dd   | 002  |
    +------+------+
    3 rows in set (0.00 sec)mysql>
      

  7.   

    SELECT * from ttg1 where f2='001' and (f1)<>'aa'
      

  8.   

    贴出你语句,应该可以啊。mysql> select * from a where f1 != 'aa' and f2='001';
    +------+------+
    | f1   | f2   |
    +------+------+
    | bb   | 001  |
    | cc   | 001  |
    +------+------+
    2 rows in set (0.00 sec)mysql> select * from a where f1 <> 'aa' and f2='001';
    +------+------+
    | f1   | f2   |
    +------+------+
    | bb   | 001  |
    | cc   | 001  |
    +------+------+
    2 rows in set (0.00 sec)mysql>
      

  9.   


    create table test
    (
    name varchar(50)
    )insert into test values('aaa');
    insert into test values('bbb');
    insert into test values('ccc');select * from test where name not in(select name from test where name like'%a%')
    有点罗嗦,可以实现LZ的功能!
      

  10.   

    select * from t where name <>'xxx' 
      

  11.   

    如果是创建表就将其约束,示例如下:create  table t(
     id int primary key,
      name varchar(15) check(name<>"xxx")
    );如是查找就是:select * from t where name <>"xxx"希望有你要的!
      

  12.   

    <>, !=, not in 自由选择
      

  13.   

    Select * from A x where x.2=='001' and x.1<>'aa'