select * from phone tem where exists (select 1 from phone where sex='女' and mobile=tem.mobile and QQ=tem.QQ)

解决方案 »

  1.   

    等价于:
    select * from phone where sex='女'and mobile is not null 
    and QQ is not null
    应该不会的。
      

  2.   

    sorry.上面的错了。应该是
    select * from phone where (sex='女'and mobile is not null )
    or QQ is not null
      

  3.   

    TO welyngj(平平淡淡): 用你的语句时还时查询到有性别为“男”的记录。
    TO pengdali(大力 V3.0):你的语句得得记录为“女”而 mobile 和QQ 都不为空。我的要求是性别必须是“女”性,mobile 列和 QQ列中至少有一个列是有数据,也可以两个列都有数据~(不好意思刚没有注释清楚)
      

  4.   

    我把语句改为:
    select * from phone
    where mobile in(select mobile from phone where sex='女')or QQ in(select QQ from phone where sex='女')
    还是出现一条“男”性的记录~
      

  5.   

    select * from phone where sex='女' and (mobile is not null or QQ is not null)