本文介绍了MySQL选择查询中AND和OR运算符的优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个mysql select query
以根据始发州,起源城市,目的地州和目的地城市获取时间表详细信息.在我的查询中,我使用了AND
和OR
运算符.
I have a written a mysql select query
to fetch schedule details based on origin states,origin city,destination state and destination city. In my query i have used AND
and OR
operator.
这是我的查询
SELECT * FROM TruckLoadSchedule ts
WHERE ts.originState IN (states) AND ts.originCity IN (cities)
OR ts.destState IN (states) AND ts.destCity IN (cities);
但是我需要知道上述查询中AND和OR运算符的优先级,我的意思是说它会在内部执行类似(X AND Y) OR (M AND Q)
的操作吗?
But I need to know the priority of AND and OR operator in the above query, i mean to say will it do something like this (X AND Y) OR (M AND Q)
internally?
推荐答案
是的,AND的优先级高于OR. x和y绑定在一起,m和q绑定在一起,然后对所得表达式进行或"运算.
Yes, AND has higher precedence than OR. x and y are bound together, m and q are bound together, then the resulting expressions are ORed.
这篇关于MySQL选择查询中AND和OR运算符的优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!