select a.ICCID,b.STB_NO
from  ir_ic_card_info_t a,ir_stb_info_t b 
where a.city_code= '119' 
and a.city_code=b.city_code 
and a.RESOURCE_KIND= '10102' 
and b.RESOURCE_KIND= '20204' 
and a.use_status=0 
and b.use_status=0 
and a.belongs_to= '10023' 
and a.belongs_to=b.belongs_to 
and rownum<= 10 这个语句查完A表字段数据正常,但B表字段数据却都是重复的。求解啊!

解决方案 »

  1.   

    SQL本身没什么问题,返回集应该按照你的业务模型来理解。
    是一对一,一对多,还是多对多
      

  2.   

    and a.city_code=b.city_code and a.belongs_to=b.belongs_to这两个是a , b 的逐渐玛? 
      

  3.   

    数据重复跟你两张表的数据有关咯,
    B表有重复数据,说明B表一条数据对应A表多条数据了
    where条件里面去控制吧