首页 新闻 会员 周边

关于Sql Server 连接查询结果重复的问题

0
悬赏园豆:5 [已解决问题] 解决于 2014-06-17 09:36
 select  a.name, a.age, b.school     from table1 a   
   left  join  table 2 b on a.name=b.name where b.city = '北京' and a.china='中国' and 
  a.height '160' and '200' 
 
 
查询出来很多重复的结果。怎么消除这些重复的结果
康大头的主页 康大头 | 初学一级 | 园豆:25
提问于:2014-05-21 10:11
< >
分享
最佳答案
0

理解了一下你的需求,你试试以下语句

select a.name, a.age, b.school from table1 a 
join (select distinct name from table2 where city='北京') b 
on a.name=b.name 
where a.china='中国' and a.height between 160 and 200
收获园豆:5
幻天芒 | 高人七级 |园豆:37175 | 2014-05-21 10:59
其他回答(4)
0
 select distinct  a.name, a.age, b.school     from table1 a   
   left  join  table 2 b on a.name=b.name where b.city = '北京' and a.china='中国' and 
  a.height '160' and '200' 
刘宏玺 | 园豆:14020 (专家六级) | 2014-05-21 10:16
0

select distinct  * from

(select  a.name, a.age, b.school     from table1 a   

   left  join  table 2 b on a.name=b.name where b.city = '北京' and a.china='中国' and 
  a.height '160' and '200'
)
t1
 
迅捷网络[来送福利] | 园豆:576 (小虾三级) | 2014-05-21 10:58
0

select distinct * from table

Albert Fei | 园豆:2102 (老鸟四级) | 2014-05-21 14:04
0

          

select distinct * from table

distinct去重复

祥子爱游戏 | 园豆:19 (初学一级) | 2014-05-22 10:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册