a表:id b c 说明:
b,c为字段名b为产品,比如玩具,汽车等
c为制造商,是生产b的厂商现在的问题是:比如,指定b的条件为玩具,那么检索出,所有制造玩具的厂商生成的产品

解决方案 »

  1.   

    select b from TB where b like '%玩具%'
      

  2.   

    select * from a t 
    where exists (select 1 from a where c=t.c and b like '%玩具%')--?
      

  3.   

    declare @name
    set @name='玩具'
    select b from TB where b like '%'+@name+'%'
      

  4.   

    继续呀,。
    select b from TB where b like '%玩具%'能行吗?
      

  5.   

    看你的b字段是什么内容了,如果汽车是1,手枪是2,... 那么select b from a where b=1 or b=2 or ....
      

  6.   

    select * from a where c in(select c from a where  st b='汽车') 
    这样不知道行不行
      

  7.   

    不是很理解你说的意思
    看看这个
    create table tb(b varchar(10), c varchar(10))
    insert tb select '玩具'   ,'上海'
    union all select '玩具'   ,'北京'
    union all select '玩具'   ,'山东'select c 
    from tb 
    where b='玩具'
    drop table tb
      

  8.   

    就是这样,比如给你一个产品
    那么就找出能生产这个产品的厂商,最终是列出这些厂商的产品比如,玩具有A,B都可以生产,那么就列出所有A,B厂商的产品
      

  9.   

    如果b字段是产品名称, 
    select * from a where c in(select c from a where b='汽车') 
    可以的阿
      

  10.   

    select * from a where c in (select c from a where b = '玩具')