select * from a 
where exists (select 1 from b where b.value=123 and b.rcid =a.rcid )

解决方案 »

  1.   

    select min(id) as id,rcid,123 as value
    from tableB group by rcid
      

  2.   

    id rcid value  ........
    1  1    123
    4  2    123select min(id) as id,rcid,value
    from b 
    where value='123'
    group by rcid,valueselect * from a where a.rcid in (select distinct(rcid) from b where value=123)
    ---->>
    select * from a where a.rcid in (select distinct(rcid) from b where value='123')
    or:
    select * from a 
    where exists (select 1 from b where b.value='123' and b.rcid =a.rcid )
      

  3.   

    select min(id) as id,rcid, min(value)
    from B where value=123 group by rcid
      

  4.   

    select distinct * from a,b where a.rcid=b.rcid and b.value=123
      

  5.   

    select min(id) as id,rcid, min(value) value
    from B where value=123 group by rcid
      

  6.   

    select * from a where a.rcid in (select distinct(rcid) from b where value=123)---->>由于A中没有RCID所以没有结果