Search Postgresql Archives

Re: Comparing first 3 numbers of a IPv4 address?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2010-11-20, Alexander Farber <alexander.farber@xxxxxxxxx> wrote:

>
> 1) if I'd like to compare just the first 3 numbers of
> the IP address instead of the 4, how can I do it?
> (yes, I know about the A,B,C type of IPv4 networks...)

 have you heard of CIDR (what about IPV6, which I'm going to ignore,
but you should consider unless this code is throw-away)
  
 just use set_masklen and the >> operator.
 
 select set_masklen('1.2.3.4'::inet,24) >> '1.2.3.244'::inet;
   
-- 
ââ 100% natural

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux