CIDR data type query help

From: "Scot Kreienkamp" <SKreien(at)la-z-boy(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: CIDR data type query help
Date: 2010-05-19 17:32:27
Message-ID: 59E62072D4EFFF4BB912EC607F8FA60BDBFEF1@lzbs6304.na.lzb.hq
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everyone,

I have a column of type CIDR in a table that I am querying that contains
the values of 10/8, 10.1/16,10.1.28/24, and 10.1.28.95. I am trying to
return only the one record that's most specific compared to the IP
address I'm currently on as this is being done in a CGI script. If
there's no specific match for the IP of the originating workstation then
it should return the /24 if it's there, then the /16 if it's there, etc.
I have never worked with the CIDR type, and a novice when it comes to
SQL query language, so I have no idea how to approach this.

Thanks for any help.

Scot Kreienkamp
skreien(at)la-z-boy(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2010-05-19 18:17:36 Re: CIDR data type query help
Previous Message Alvaro Herrera 2010-05-19 16:26:11 Re: Help writing a query to predict auto analyze