贴建表及插入记录的SQL,及要求结果出来看看

解决方案 »

  1.   

    select *
    from 表b t
    where exists (select 1 from 表a where not exists (select 1 from 表b where name=t.name and typeid=表a.id ))
      

  2.   

    select name
    from b
    group by name
    having count(distinct typeid)<5
      

  3.   

    select name
    from b
    group by name
    having count(distinct typeid)<5 +1
      

  4.   

    select * from b t
    where exists(seldct 1 from a where not exists(seldct 1 from 
    b where name=t.name and typeid=a.id);