notBetween 外查询
notBetween ecto query
我有一个查询 return 结果 between
我们在参数中传递给它的 values
如果我们像这样传递 [value1, value2]
:
where: field(name) > ^Enum.min(value 1)
and field(name) < ^Enum.max(value 2)
它 return 正在 value1
和 value 2
之间的记录。
我想实施notbetween
。这将 return 记录 less than value1
和 greater than value 2
有什么建议吗?
谢谢
will return records less than value1
and greater than value 2
只需反转条件(注意 or
到 return 较小的或较大的):
where: field(name) < ^Enum.min(value 1)
or field(name) > ^Enum.max(value 2)
我有一个查询 return 结果 between
我们在参数中传递给它的 values
如果我们像这样传递 [value1, value2]
:
where: field(name) > ^Enum.min(value 1)
and field(name) < ^Enum.max(value 2)
它 return 正在 value1
和 value 2
之间的记录。
我想实施notbetween
。这将 return 记录 less than value1
和 greater than value 2
有什么建议吗?
谢谢
will return records
less than value1
andgreater than value 2
只需反转条件(注意 or
到 return 较小的或较大的):
where: field(name) < ^Enum.min(value 1)
or field(name) > ^Enum.max(value 2)