SELECT * from ttp1 a where exists(select 1 from ttp1 where 编号=a.编号 and 产品名='内衣') and not exists(select 1 from ttp1 where 编号=a.编号 and 产品名='外套')
and 产品名='牛仔裤'
SQL code
select distinct 编号 from table1 a
where 产品名='牛仔裤'
and not exists (select 1 from table1 where 编号=a.编号 and 产品名!='牛仔裤')
[/Quote]
高手能不能解释下:select 1 from table1 where 编号=a.编号 and 产品名!='牛仔裤'他啊