您当前的位置:首页 > CMS常见问题 > ecshop常见问题 >

ecshop 属性筛选sql语句

0

列出商品分类ID为1商品类型属性ID为221的所有能单独销售的上架的普通商品的goods_attr_id(具体商品的属性表的goods_attr_id), attr_id(商品类型属性表的attr_id), attr_value(该具体属性的值)三个字段的值

select 
	a.goods_attr_id,
	a.attr_id,
	a.attr_value as attr_value 
from ecs_goods_attr as a, ecs_goods as g 
where (g.cat_id in ('1') or g.goods_id in ('')) 
and g.goods_id = a.goods_id 
and g.is_delete = 0 
and g.is_on_sale = 1 
and g.is_alone_sale = 1 
and a.attr_id = 221 
order by g.goods_id desc,
	 a.attr_id asc,
	 a.goods_attr_id asc

sql语句输出

select 
	a.goods_attr_id,
	a.attr_id,
	a.attr_value as attr_value 
from ecs_goods_attr as a, ecs_goods as g 
where (g.cat_id in ('1') or g.goods_id in ('')) 
and g.goods_id = a.goods_id 
and g.is_delete = 0 
and g.is_on_sale = 1 
and g.is_alone_sale = 1 
and a.attr_id = 221 
group by attr_value 
order by g.goods_id desc,
	 a.attr_id asc,
	 a.goods_attr_id asc

select 
	min(a.goods_attr_id) as goods_id,
	a.attr_id,
	a.attr_value as attr_value 
from ecs_goods_attr as a, ecs_goods as g 
where (g.cat_id in ('1') or g.goods_id in ('')) 
and g.goods_id = a.goods_id 
and g.is_delete = 0 
and g.is_on_sale = 1 
and g.is_alone_sale = 1 
and a.attr_id = 221 
group by attr_value 
order by g.goods_id desc,
	 a.attr_id asc,
	 a.goods_attr_id asc

建站咨询

在线咨询真诚为您提供专业解答服务

咨询热线

137 1731 25507×24小时服务热线

微信交流

二维码终于等到你,还好我没放弃
返回顶部