ALTER TABLE `yf_discount_goods` ADD INDEX `common_id` (`common_id`);
ALTER TABLE `yf_discount_goods` ADD INDEX `goods_id` (`goods_id`);
ALTER TABLE `yf_groupbuy_base` ADD INDEX `common_id` (`common_id`);
ALTER TABLE `yf_groupbuy_base` ADD INDEX `groupbuy_state` (`groupbuy_state`);
ALTER TABLE `yf_increase_goods` ADD INDEX `goods_id` (`goods_id`);
ALTER TABLE `yf_mansong_rule` ADD INDEX `goods_id` (`goods_id`);
####
ALTER TABLE `yf_goods_images` ADD INDEX `images_color_id` (`images_color_id`);
ALTER TABLE `yf_goods_images` ADD INDEX `common_id` (`common_id`);
ALTER TABLE `yf_order_goods` ADD INDEX `goods_id` (`goods_id`);
ALTER TABLE `yf_base_district` ADD INDEX `district_name` (`district_name`);
ALTER TABLE `yf_web_config` ADD INDEX `config_key` (`config_key`);
ALTER TABLE `yf_goods_cat_nav` ADD INDEX `goods_cat_id` (`goods_cat_id`);
ALTER TABLE `bbc`.`yf_order_goods` ADD INDEX `common_id` (`common_id`);
ALTER TABLE `bbc`.`yf_order_goods` ADD INDEX `buyer_user_id` (`buyer_user_id`);
### 活动SQL
#限时折扣
select *
from yf_discount_goods as a,yf_discount_base as b
where
a.discount_id = b.discount_id and
# 状态, 1-正常/2-结束/3-管理员关闭
b.discount_state = 1 and
a.goods_id = 111
#团购
select * from
yf_groupbuy_base as a
where
# 1.审核中 2.正常 3.结束 4 .审核失败 5.管理员关闭
groupbuy_state = 2 and
a.common_id = 1
#加价购
select *
from yf_increase_goods as a,yf_increase_base as b
where
a.increase_id = b.increase_id and
# 状态, 1-正常/2-结束/3-管理员关闭
b.increase_state = 1 and
a.goods_id = 111
#满即送
select *
from yf_mansong_rule as a,yf_mansong_base as b
where
a.mansong_id = b.mansong_id and
# 1-正常/2-已结束/3-管理员关闭,取消
b.mansong_state = 1 and
a.goods_id = 111
#拼团
select *
from yf_pintuan_detail as a,yf_pintuan as b
where
a.pintuan_id = b.id and
# 是否可用,1为可用。
b.status = 1 and
a.goods_id = 111