查询以检查IP地址是否在表中的startIP和EndIp列的范围内

时间:2019-05-23 09:09:20

标签: postgresql postgresql-9.3 node-postgres

我需要阻止某些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)
   }
  ))
 })

0 个答案:

没有答案