oracle and里面嵌套and问题我想知道and()这个语法是什么意思?还有and t22.busType in ('4','6','7') or t11.maType'2'这个语法是什么意思?and t22.num is not null and (t11.type in ('1','2') and t11.maType='2' and t22.busType
oracle and里面嵌套and问题
我想知道and()这个语法是什么意思?还有and t22.busType in ('4','6','7') or t11.maType<>'2'这个语法是什么意思?
and t22.num is not null
and (
t11.type in ('1','2')
and t11.maType='2'
and t22.busType in ('4','6','7') or t11.maType<>'2'
)
这个不叫and 里嵌套and
首先
and t22.busType in ('4','6','7') or t11.maType'2'这个意思是
将复合t22.busType in ('4','6','7')这个条件的数据给我拿出来并且把t11.maType'2'
的数据也给我拿出来
一般 有or 才会用括号()
再给你解释下面这个语句
and (
t11.type in ('1','2')
and t11.maType='2'
and t22.busType in ('4','6','7') or t11.maType'2'
)
这个括号就是给OR用的
2部分数据需要给我拿出来
第一部分:
t11.type in ('1','2')
and t11.maType='2'
and t22.busType in ('4','6','7')
第二部分:
t11.maType'2'
不知道你明白没?
相当于
A && (B || C) A为真,B和C中有一个为真结果为真 false && (false || true) 结果是false
如果是
A && B || C 相当于 (A && B) || C false && false || true 结果是true
和你这sql 一样的道理,优先级问题
and相当这里的&& ;or相当||
and 不就是并且吗 条件a and 条件b 就是既要满足条件a又要满足条件b的数据
你这个sql是说t22.num不能为空 并且要满足 t11.type 不是1就是2
并且 t11.maType=2
并且 t22.busType 要是4,5,6中的一个
或者 t11.maType 不等于2
的数据
and() 我觉得只是为了...
全部展开
and 不就是并且吗 条件a and 条件b 就是既要满足条件a又要满足条件b的数据
你这个sql是说t22.num不能为空 并且要满足 t11.type 不是1就是2
并且 t11.maType=2
并且 t22.busType 要是4,5,6中的一个
或者 t11.maType 不等于2
的数据
and() 我觉得只是为了将括号中的条件 与其他条件分开来。
收起