首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

oracle sql 搜索数据重复解决思路

2013-01-25 
oraclesql搜索数据重复select a.* from wcm_site a,wcm_siteright b where (b.rightnoteAD025 or b.rig

oracle sql 搜索数据重复

select a.* from wcm_site a,wcm_siteright b where (b.rightnote='AD025' or b.rightnote in ('1','3')) and a.id=b.siteid and a.id like '____' order by a.id;

因为一个wcm_site对应多个wcm_siteright,所以结果会重复,两表没有关联.
[解决办法]

--这样就不会有重复了
select a.* from wcm_site a
where exists (select * from wcm_siteright b
where a.id=b.siteid and (b.rightnote='AD025' or b.rightnote in ('1','3')))
and a.id like '____' 
order by a.id;

热点排行