1. 少用 in not in select id from t where num in(1,2,3) -> select id from t where num between 1 and 3 ;

2. 少用 or 来连接where子句: select id from t where num=10 or num=20 -> 

select id from t where num=10  

union all  

select id from t where num=20 

3. 避免where子句中用 null 筛选,用 默认值代替 null select id from t where num is null ->  select id from t where num=0 ;

4. 避免在where子句中对字段进行表达式操作 select id from t where num/2=100 -> select id from t where num=100*2 ;

 

相关文章:

  • 2021-06-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-11
  • 2021-08-02
相关资源
相似解决方案