有这么一段sql
select c.attr_value from ecs_goods_attr c where c.goods_id in
(select a.goods_id from ecs_goods a where a.goods_name='s020039');
因为我事先知道c.attr_value包涵一个值是apson,
我想排除掉这个值,取余下的其它的值,该怎么写

解决方案 »

  1.   

    select c.attr_value 
    from ecs_goods_attr c 
    where c.goods_id in 
    (select a.goods_id from ecs_goods a where a.goods_name='s020039')
    and c.attr_value !=  'apson';
      

  2.   

    select c.attr_value from ecs_goods_attr c 
    inner join ecs_goods a
    on c.goods_id=a.goods_id
    where a.goods_name='s020039'
      

  3.   

    select c.attr_value from ecs_goods_attr c
    inner join ecs_goods a
    on c.goods_id=a.goods_id
    where a.goods_name='s020039' and c.attr_value<>'apson'
      

  4.   

    select c.attr_value from ecs_goods_attr c where c.goods_id in
    (select a.goods_id from ecs_goods a where a.goods_name='s020039' and a.attr_value<>'apson');