【问题标题】:SQL Where to exclude range using two variablesSQL Where 使用两个变量排除范围
【发布时间】:2020-04-14 20:16:25
【问题描述】:

我正在尝试创建一个 WHERE 语句,其中不包括坐标的平方。

我已经在一张表上保存了一些带有 X 和 Y 坐标的记录。

我想排除 x1 和 x2 以及 y1 和 y1 之间的记录

我正在使用

select * from dbo.records where (x not between x1 and x2)  and  (y not between y1 and y2)

但是第一个不是中间是删了我很多坐标

enter image description here

你知道获得正方形内坐标的方法吗?

谢谢

【问题讨论】:

    标签: sql range coordinates where-clause between


    【解决方案1】:

    我认为你想要ored 条件:

     where (x not between x1 and x2) or (y not between y1 and y2)
    

    我发现将其表述为:

     where not (x between x1 and x2 and y between y1 and y2)
    

    条件x between x1 and x2 and y between y1 and y2定义属于正方形的坐标;您需要不满足这些条件的坐标。

    【讨论】:

    • 是的。谢谢!。我从来没有见过。
    猜你喜欢
    • 2014-05-02
    • 1970-01-01
    • 2013-10-10
    • 2013-01-13
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多