表pprstock字段如下:  ID  产品名称  原料ID   类型
            1    球节    12    合金
            2    球节    13    毛坯
            3    底座    10    合金
            4    垫圈    11    钢材
            5    大球    9     毛坯
 
请问如何得到如下的查询结果:ID  产品名称  原料ID  类型
              3   底座     10   合金
              4   垫圈     11   钢材
也就是说得到该表中所有不包含“毛坯”类型的产品信息
请问这个Sql语句如何写

解决方案 »

  1.   

    select * from pprstoc where 类型<>'毛坯'
      

  2.   

    select * from pprstock as a where not exists
    (select * from pprstock where a.产品名称=产品名称 and 类型='毛坯')
      

  3.   

    declare @t table(ID int,产品名称 varchar(10),原料ID int,类型 varchar(10))
    insert into @t select 1,'球节',12,'合金'
    union all select 2,'球节',13,'毛坯'
    union all select 3,'底座',10,'合金'
    union all select 4,'垫圈',11,'钢材'
    union all select 5,'大球',9,'毛坯'select * from @t a where not exists(select 1 from @t where 产品名称=a.产品名称 and 类型='毛坯')
      

  4.   

    select * from pprstock where 类型<>'毛坯'
      

  5.   


    select * from pprstock  where 类型!='毛坯'
      

  6.   

    select * from pprstock a where not exists(select 1 from pprstock where 产品名称=a.产品名称 and 类型='毛坯')
      

  7.   

    xeqtr1982(ShaKa) 能解释一下思路吗?