1. 首页
  2. 数据库
  3. 其它
  4. SQL UNION vs OR 性能

SQL UNION vs OR 性能

上传者: 2020-12-30 19:31:33上传 PDF文件 69.24KB 热度 24次
本文整理自:stackoverflow 翻译自Bill Karwin回答: 要么你读的那篇文章用了一个不好的例子,要么你误解了他们的观点。 select username from users where company = 'bbc' or company = 'itv'; 等价于: select username from users where company IN ('bbc', 'itv'); 在这个查询中MySQL会使用company上的索引。不需要改成UNION。 更棘手的情况是,OR条件涉及两个不同的列。 select username from users where c
下载地址
用户评论