优化之索引:
alter table go_member_go_record add INDEX `sindex`(`present`,`is_jiqi`,`shop_status`);
首先不同的表是无法使用索引的,联合索引指的是同一张表的不同字段。优化需要看两张表数据量。一般的做法是:select * from (select * from A where X = 'xxxx') as aa left join B on B.id=aa.id order by B.datetime;建立 单独对A.X A.id B.id 建立索引。
追问
你确定是用的是mysql吗?
你确定mysql按照如下的写法可以查到数据吗?
select * from (select * from A)
追答
当然是MySQL, select * from (select * from A) as aa 要加别名的。这个叫嵌套查询,里面的句子叫子查询,目的是缩小范围。
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
人人得宝,出现mobile重复出现,解决方法:
//添加普通索引
create index mobile on go_member(mobile);
//将所有mobile重复记录导入第三表 go_all
create table go_all select * from go_member where 1=2
insert into go_all select * from go_member where mobile in (select mobile from go_member group by mobile having count(*)>1);
//将mobile重复记录中uid最小记录导入第三表 go_min
create table go_min select * from go_member where 1=2
insert into go_min select * from go_member where mobile!='' or mobile is not null group by mobile having count(*)>1;
//删除mobile重复且uid非最小记录
delete from go_member where uid in(select uid from go_all) and uid not in(select uid from go_min);
//添加mobile唯一索引
alter table go_member add unique(mobile);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
解决方法:
delete from menu_item where parent_id =(select menu_item_id from menu_item where menu_data like '%manageVendors%');
delete from menu_item where parent_id =(select temp.menu_item_id from (select m.menu_item_id,m.menu_data from menu_item m) temp where temp.menu_data like '%manageVendors%');
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++