at least 
only
这两种条件用什么实现呢?

解决方案 »

  1.   

    dutysmart (DUTYSMART)
      '截至2010-03-27 16:23:21  用户结帖率43.28%  总发帖:201  正常结帖:75  未结帖:114  
      

  2.   

    比如name='a'的记录有2条,name='b'的有3条,
    现在想找只有一条记录的,怎么做呢?
    如果想找至少有一条记录的怎么做呢?
      

  3.   

    这样做,查找2条记录的
    select id ,name from tab
    where name='a'
    group by id
    having count(name)=2
      

  4.   

    至少有一条的
    select id ,name from tab
    where name='a'
    group by id
    having count(name)>1
      

  5.   

    select * from a where (select count(*) from b where a.i=b.i)=1;
    select * from a where (select count(*) from b where a.i=b.i)>0;这样写可以吗
      

  6.   

    不可以
    select count(*) from b where a.i=b.i 这条语句返回的很可能是个结果集 没法与0,1进行比较
    应该使用 group by ...having...
      

  7.   

    应该是
    select id from tab
    group by name
    having count(id)>1
    这样吧?