发新话题
打印

更新所以商品的关键字

更新所以商品的关键字

现在已经添加了几百件商品,自定义了三种商品类型,现在想把每件商品的属性(自定义类型中的)加入到关键字里,想用查询语句实现,看我的"中文式SQL":
update ecs_goods set keywords=(
(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='182')+' '+
(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='183')+' '+
(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='176')+' '+
(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='175'))
where goods_type='10'
大家能理解吗?
update ecs_goods set keywords=(......) where goods_type='10'中的红色部分是我的自定的一种商品类型;
要替换成的值是属性表中的属性是182,183,176,175几条记录相连的值.
不知道大家理解我的意思了吗?
当然,很显然的,我的这个查询是失败的|||

TOP

吼吼吼~~

TOP

已解决:
update ecs_goods set keywords= (select concat((select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='182'),(select if((select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='183') is NULL,'',concat(' ',(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='183'))) from dual),(select if((select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='176') is NULL,'',concat(' ',(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='176'))) from dual),(select if((select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='175') is NULL,'',concat(' ',(select attr_value from ecs_goods_attr where ecs_goods.goods_id=ecs_goods_attr.goods_id and attr_id='175'))) from dual)) from dual) where goods_type='10'
本帖最近评分记录

TOP

发新话题