Need help with Inet type

From: Eric Lamer <eric(dot)lamer(at)intact(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Need help with Inet type
Date: 2013-09-10 16:46:00
Message-ID: OF89EC909B.4B35626C-ON85257BE2.005C122D-85257BE2.005C1A8A@intact.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2013-09-10 17:26:03 Re: help getting a backtrace from 9.2 on Ubuntu 13.04?
Previous Message Muhammad Bashir Al-Noimi 2013-09-10 15:55:31 PG9.1 Static build over Windows