MYSQL: OR -->UNION

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)