1. 负向条件查询不能使用索引 select * from order where status!=0 and stauts!=1 not in/not exists都不是好习惯 可以优化为in查询: select * from order where status in(2,3) 2. 前导模糊查询不能使用索引 select * from order where desc like '%XX' 而非前导模糊查询则可以: select * from order where desc like '…
这几天在写索引,想到一些有意思的TIPS,希望大家有收获. 一.一些常见的SQL实践 (1)负向条件查询不能使用索引 select * from order where status!=0 and stauts!=1 not in/not exists都不是好习惯 可以优化为in查询: select * from order where status in(2,3) (2)前导模糊查询不能使用索引 select * from order where desc like '%XX' 而非前导模糊查…
一.一些常见的SQL实践 (1)负向条件查询不能使用索引 select * from order where status!=0 and stauts!=1 not in/not exists都不是好习惯 可以优化为in查询: select * from order where status in(2,3) (2)前导模糊查询不能使用索引 select * from order where desc like '%XX' 而非前导模糊查询则可以: select * from order wher…
基础操作 一:MySQL基础操作 1:MySQL表复制 复制表结构 + 复制表数据 create table t3 like t1; --创建一个和t1一样的表,用like(表结构也一样) insert into t3 select * from t1; --t1的数据全部拿过来,注意是表结构一致才select* ,否则选择相应的的字段列插入 c…