postgresql - 查询IP地址是否在表中startIP和EndIp列的范围内
问题描述
我需要阻止一些 IP 地址访问我的应用程序。我需要使用 postgres 编写一个查询来检查 IP(动态到来)是否落在存储在数据库中的 startip 和 endip 之间的任何范围内。
Arr.forEach((element,index)=>{
client.query("select exists(select 1 from data where ip_start=$1 OR ip_end = $2 between ip_start and ip_end)",
[Arr[index].ip,Arr[index].ip])
.then((res =>{console.log(res)
}
))
})
解决方案
推荐阅读
- javascript - Highcharts 6时间线图
- excel - 我如何想出一个公式来解决以下问题:如果一个单元格为零,则将另一个单元格中的一个数字添加到总成本中?
- redmine - Redmine Rest API - 文件附件,上传令牌不完整
- python - 读取多个 JSON 文件并将数据转换为单个 CSV 文件
- ms-access - 用于多个查询的 MS Access 报告
- javascript - echarts:dataZoom 滑块不显示正确的数据预览
- java - 重新索引 Solr:java.lang.OutOfMemoryError:Java 堆空间 solr
- groovy - 如何在 Groovy 中获取函数的输出
- android - Firebase IOS UTM 安装跟踪
- angular - Angular 8 上传中的多部分/表单数据