T-SQL AND 逻辑
我有表 TABLE1,其中包含 A、B 和 C 列。我需要从表中获取 A、B 和 C 列不全部等于 1 的所有行,例如,
WHERE NOT (A = 1 AND B = 1 AND C = 1)
这有效。但是,我需要以仅使用 AND 和 OR 语句的方式执行此操作。我原以为这会起作用:
WHERE A != 1
AND B != 1
AND C != 1
但是,这只返回没有 row = 1 的行,即行太少。
使用 MS SQL 2008。
I have table TABLE1 with columns A, B and C. I need to get all rows from the table where columns A, B and C are not all equal to 1, e.g.,
WHERE NOT (A = 1 AND B = 1 AND C = 1)
This works. However, I need to do this in a fashion that only uses AND and OR statements. I had expected this to work:
WHERE A != 1
AND B != 1
AND C != 1
However, this only returns rows where no row = 1, i.e, too few rows.
Using MS SQL 2008.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)