试一下吧
select tb1.学号,tb1.姓名,tb2.序号,tb2.科目名称
from tb1,tb2 where tb1.学号=tb2.学号
order by 姓名

解决方案 »

  1.   

    如果有人可以"只能用一句SQL语句实现",请告诉我,谢谢!
      

  2.   

    把你的数据发过来
    我用别的方法试试
    [email protected]
      

  3.   

    select a.学号,a.姓名,b.序号,b.科目名称 from tb1 a,tb2 b where a.学号=b.学号
    and exists(select 学号,count(*) from tb2 group by 学号 haiving count(*).1>1 where tb2.学号=tb1.学号) 没试过,不知道行不行:)
     
      

  4.   

    可以统计人名,用count(),统计数字大于1的就是报考科目多于1的.
      

  5.   

    select tb1.xh,tb1.name,tb2.xh,tb2.km 
    from tb1,tb2
    where (tb1.xh = tb2.xh) and count(tb1.name) > 1
    order by tb1.name
      

  6.   

    select a.学号,a.姓名,b.序号,b.科目名称 from tb1 a inner join tb2 b on a.学号=b.学号 where a.学号 in(Select 学号 From TB2 Group by 学号 Having Count(序号)>1)
      

  7.   

    xh:学号;
    xm:姓名;
    no:序号;
    km:科目;
    select 
      a.xh,a.xm,b.no,b.km 
    from 
      tb1 a,tb2 b 
    where 
      a.xh=b.xh 
      and a.xh in 
    (select xh from (select xh,count(*) as num from tb2 group by xh) as temptable where num>1)这个一定好用的,我试过了!
    100分,我好心动!
      

  8.   

    Select 学号,(Select 姓名 From Table1 Where 学号=Table2.学号) As 姓名,
    科目,(Select 序号 From Table1 Where 学号=Table2.学号) As 序号
    From Table2 
    Where 学号 in (Select 学号 From Table2 Group by 学号 Having Count(序号)>1)
      

  9.   

    或者这样也是可以的了
    select 
      a.xh,a.xm,b.no,b.km 
    from 
      tb1 a,tb2 b 
    where 
      a.xh=b.xh 
      and a.xh in 
    (select xh from (select xh,count(*)as num from tb2 group by xh having count(*)>1) as temptable)
      

  10.   

    又可以少一点
    select 
      a.xh,a.xm,b.no,b.km 
    from 
      tb1 a,tb2 b 
    where 
      a.xh=b.xh 
      and a.xh in 
    (select xh from (select xh from tb2 group by xh having count(*)>1)as T)
      

  11.   

    其实我提问后,也在看这个问题,问题早已解决:
    具体的内容是:
    Select  TB1.学号,TB1.姓名,TB2.序号,TB3.科目名称
    From TB1,TB2,
    (Select 学号,Count(*) 科目数 From TB1,TB2 Where TB1.学号=Tb2.学号 Group By 学号) TB3
    Where TB1.学号=Tb2.学号
    And TB1.学号=Tb3.学号
    And Tb3.科目数>1
    Order By 姓名仅供参考,感谢所有支持我的朋友,来者有分!!!