sql查询claus
我有这个条款的
WHERE (ACCDAT_0 >= '2020-01-01 00:00:00.000')and STA_0='3'
and
(NUM_0 LIKE '%FTC%') OR (NUM_0 LIKE '%NCC%') OR (NUM_0 LIKE '%DCF%')
重点是,如果sta_0 ='1'
出现在查询中,因为它就像NCC一样,除了标志为1的ncc以外,所有NCC都可以出现所有NCC吗?
I have this where clause
WHERE (ACCDAT_0 >= '2020-01-01 00:00:00.000')and STA_0='3'
and
(NUM_0 LIKE '%FTC%') OR (NUM_0 LIKE '%NCC%') OR (NUM_0 LIKE '%DCF%')
The point is that if STA_0='1'
is appearing in the query because its like NCC it possible to appear all NCC except the ones where the flag is 1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这确实是一个评论,但是它太大了,无法适合评论空间...对我上面的评论进行了详细说明。
“或”是一个低优先级操作员,这意味着它在所有毕竟都会进行评估。这意味着您的查询是这样做的:
意味着如果num_0就像ncc或dcf一样,则忽略了前两个条件。那可能不是您的意思,但这就是您所说的。
您可能意味着这个问题:
更大的教训是……如果您混合使用,并且,或者,请确保使用括号,以便它确实做到了您的意思。
This is really a comment, but it's too large to fit in the comment space... elaboration on my comment above.
"OR" is a low precedence operator, meaning it is evaluated after all "AND." What this means is your query is doing this:
Meaning if NUM_0 is like NCC or DCF, then the first two criteria are ignored. That may not be what you meant, but that's what you said.
You might have meant this:
And the larger lesson is... if you mix AND and OR, be sure to use parentheses so it does exactly what you mean.