这两个查询之间有区别吗? [英] Is there a difference between these two queries?
本文介绍了这两个查询之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我认为这是一个非常简单的问题,但我找不到令人满意的答案. 这两个查询之间有区别吗?
Well, pretty simple question I think, but I can't find a satisfying answer. Is there a difference between these two queries?
SELECT * FROM table WHERE column1 = 'x' OR column2 = 'x'
SELECT * FROM table WHERE (column1 = 'x' OR column2 = 'x')
预先感谢
推荐答案
现在,您的查询中存在否差异.
Right now there is NO difference in your queries.
如果在查询中添加AND
条件,则会有所不同.
There would be difference if there would be AND
condition as addition in your query.
例如
SELECT * FROM table WHERE id=1 AND column1 = 'x' OR column2 = 'x'
和
SELECT * FROM table WHERE id=1 AND (column1 = 'x' OR column2 = 'x')
注意
SELECT * FROM table WHERE id=1 AND column1 = 'x' OR column2 = 'x'
将等同于
SELECT * FROM table WHERE (id=1 AND column1 = 'x') OR column2 = 'x'
这篇关于这两个查询之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文