比如有这么一个表:
fid name sex1 a 男2 b 男3 c 女4 d 女5 a 男6 b 男我想要的查询结果是:
3 c 女4 d 女这个该怎么查呢?
fid name sex1 a 男2 b 男3 c 女4 d 女5 a 男6 b 男我想要的查询结果是:
3 c 女4 d 女这个该怎么查呢?
解决方案 »
- Spring使用IOC是为了实现“开闭原则”
- 谈谈spring事务管理
- wap开发,jsp页面中如何获取手机号码?
- SOS SOS
- 请问下有Ejb3+Spring3+SpringMVC的例子嘛,或者讲讲他们之间怎么调用?
- 超级困难问题:关于一个应用必须使用两个相同包问题。例如:一个应用必须使用两个Log4j包(但是版本不同,不能统一使用一个),请问怎么解决
- 请问:如何根据.hbm.xml文件自动生成对应的表?
- 有采用Java语言开发的OS多媒体通信项目么?不是很熟悉,具备基本的视频/音频能力即可,不要求企业级稳定性和功能~
- 小弟想学java,苦于一窍不通,又急于短期速成急用,求助于各位大虾,介绍一些入门书籍和经验
- MM請哥哥指教
- servlet调用dll问题,Can't find dependent libraries
- 请教一个jcom在web上应用的问题
1楼是正解
where sex='女';
这时就得出你的结果了
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
where (select count(1) from your_table
where name = a.name
and sex = a.sex) = 1
SQL语句你多写写就有感觉了