Re: Comparing first 3 numbers of a IPv4 address?

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Comparing first 3 numbers of a IPv4 address?
Дата
Msg-id id3g19$ipe$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Comparing first 3 numbers of a IPv4 address?  (Alexander Farber <alexander.farber@gmail.com>)
Список pgsql-general
On 2010-11-20, Alexander Farber <alexander.farber@gmail.com> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: How to find correct locale name for CREATE DATABASE
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: finding rows with invalid characters