比如有这么一个表:
fid   name  sex1     a      男2     b      男3     c      女4     d      女5     a      男6     b      男我想要的查询结果是:
3     c      女4     d      女这个该怎么查呢?

解决方案 »

  1.   

    lz,对你实在是佩服,你看看,你要查的不都是女的吗,where sex=“女”不就可以了。
      

  2.   

    楼上正解,你还想过滤?加distinct吧
      

  3.   

    lz,对你实在是佩服,你看看,你要查的不都是女的吗,where sex=“女”不就可以了。
    1楼是正解
      

  4.   

    select * from table_name(表名)
    where sex='女';
    这时就得出你的结果了
      

  5.   

    我想LZ不至于连最基本的sql都不会的,这里应该只是数据上出了问题,LZ应该是想选择没有重复的数据
    select a.fid, a.name, a.sex from your_table a
    where not exists (select 1 from your_table 
                       where name = a.name 
                         and sex = a.sex 
                         and fid != a.fid) 或者select a.fid, a.name, a.sex from your_table a
    where (select count(1) from your_table 
             where name = a.name 
               and sex = a.sex) = 1 
      

  6.   

    select a.fid, a.name, a.sex from your_table a
    where (select count(1) from your_table 
             where name = a.name 
               and sex = a.sex) = 1 
    SQL语句你多写写就有感觉了