美文网首页
MYSQL: OR -->UNION

MYSQL: OR -->UNION

作者: 0_Eric | 来源:发表于2017-05-09 18:35 被阅读0次

    select * from orders where (customer_num = 104 and order_num > 1001) or order_num = 1008

    虽然在customer和order上面建立了索引,但是上面的语句中优化器还是使用顺序存取路径扫描整个表,应该为如下:

    select * from orders where customer_num = 104 and order_num > 1001

    UNION

    select * from orders where order_num = 1008

    相关文章

      网友评论

          本文标题:MYSQL: OR -->UNION

          本文链接:https://www.haomeiwen.com/subject/musitxtx.html