Need help with Inet type
От | Eric Lamer |
---|---|
Тема | Need help with Inet type |
Дата | |
Msg-id | OF89EC909B.4B35626C-ON85257BE2.005C122D-85257BE2.005C1A8A@intact.net обсуждение исходный текст |
Ответы |
Re: Need help with Inet type
Re: Need help with Inet type |
Список | pgsql-general |
Hi,
I would like to know if there is a way to do what I need with Postgress.
I have a table with logs and a table with a list of subnets.
Right now I do the following query in my table:
Select * From logs Where src_ip << '10.0.0.0/24' OR src_ip << '10.1.0.0/24' OR src_ip << '172.168.1.0/28';
I would like to simplify that query and use a table instead as the source of the subnet I want to check.
I have a table that contain a list of subnet and zone name:
ZONE_a 10.0.0.0/24
ZONE_a 10.1.0.0/24
ZONE_a 172.16.1.0/28
ZONE_b 10.2.0.0/24
ZONE_b 10.3.0.0/24
I can do something like:
Select * From logs Where src_ip IN (Select ip from ip_table where zone = 'ZONE_a');
Of course that does not work since it does not work with Inet type and I cannot use << because I have more than 1 row return from the second select.
Is there a way to achive that?
Thanks.
_______________________
Eric Lamer
IT Security Specialist
INTACT Financial Corporation
(450) 778-9580 ext. 3744
I would like to know if there is a way to do what I need with Postgress.
I have a table with logs and a table with a list of subnets.
Right now I do the following query in my table:
Select * From logs Where src_ip << '10.0.0.0/24' OR src_ip << '10.1.0.0/24' OR src_ip << '172.168.1.0/28';
I would like to simplify that query and use a table instead as the source of the subnet I want to check.
I have a table that contain a list of subnet and zone name:
ZONE_a 10.0.0.0/24
ZONE_a 10.1.0.0/24
ZONE_a 172.16.1.0/28
ZONE_b 10.2.0.0/24
ZONE_b 10.3.0.0/24
I can do something like:
Select * From logs Where src_ip IN (Select ip from ip_table where zone = 'ZONE_a');
Of course that does not work since it does not work with Inet type and I cannot use << because I have more than 1 row return from the second select.
Is there a way to achive that?
Thanks.
_______________________
Eric Lamer
IT Security Specialist
INTACT Financial Corporation
(450) 778-9580 ext. 3744
В списке pgsql-general по дате отправления: