首页 > 解决方案 > 查询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)
   }
  ))
 })

标签: postgresqlpostgresql-9.3node-postgres

解决方案


推荐阅读