select * from a t where exists (select 1 from a where c=t.c and b like '%玩具%')--?
declare @name set @name='玩具' select b from TB where b like '%'+@name+'%'
继续呀,。 select b from TB where b like '%玩具%'能行吗?
看你的b字段是什么内容了,如果汽车是1,手枪是2,... 那么select b from a where b=1 or b=2 or ....
select * from a where c in(select c from a where st b='汽车') 这样不知道行不行
不是很理解你说的意思 看看这个 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
where exists (select 1 from a where c=t.c and b like '%玩具%')--?
set @name='玩具'
select b from TB where b like '%'+@name+'%'
select b from TB where b like '%玩具%'能行吗?
这样不知道行不行
看看这个
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
那么就找出能生产这个产品的厂商,最终是列出这些厂商的产品比如,玩具有A,B都可以生产,那么就列出所有A,B厂商的产品
select * from a where c in(select c from a where b='汽车')
可以的阿