postgresql - how to select IPs in same network in SQL -


i have table include ip addresses , netmasks, want select ips table in same network network address.

   ip_adress    |  netmask ----------------|-----------  192.168.13.25  |    29      192.168.13.26  |    29  192.168.13.1   |    30  192.168.13.2   |    30 

for example, want ips table in network address 192.168.13.24/29:

   ip_adress    |  netmask ----------------|-----------  192.168.13.25  |    29      192.168.13.26  |    29 

using postgresql's network address functions , operators can easly :

select * network_adresse_table  network(cast(format('%1$s/%2$s',ip_adress,netmask) inet)) =  cast('192.168.13.24/29' inet) 

here sql fiddle


Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -