我select 分别得到两张表 
我需要找到其中名字重复的学校 然后将名字重复的学校筛选出来成为一个表 就像这样  这个SQL语句怎么写SQLselect

解决方案 »

  1.   

    if object_id('t') is not null drop table t
    create table t
    (
    name varchar(20),
    number int
    )insert into t
    select '安庆师范学院',536 union
    select '安顺学院',508 union
    select '安阳工学院',532 union
    select '安阳工学院',516 union
    select '安阳师范学院',530 union
    select '安阳师范学院',510 union
    select '鞍山师范学院',534 union
    select '百色学院',509 union
    select '百色学院',533 union
    select '保定学院',509
    goselect t.name
    from
    t
    group by t.name
    having COUNT(t.name)>1
      

  2.   

    select a.name from A inner join B on a.name=b.name
      

  3.   

    select distinct name from A
    union 
    select distinct name from B