pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Datatype Inet and Searching
3+ messages / 3 participants
[nested] [flat]

* Datatype Inet and Searching
@ 2003-12-02 23:50  Devin Atencio <devin@burgoyne.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Devin Atencio @ 2003-12-02 23:50 UTC (permalink / raw)
  To: pgsql-sql

 

Dear Users,

 

I am very new to using the inet data type and I have a database with a list
of CIDRs in it

And I was hoping to be able to do some kind of select statement that would
pull the record

That the IP given is located in for example. If in my database I have a
record like:

 

Id          cidr                   name

1          10.0.0.0/30        user1

2          10.0.0.4/30        user2

3          10.0.0.8/30        user3

 

I was hoping to be able to do something like:

Select * from mytable where cidr <<='10.0.0.5'

 

And the database would return only record 2 since it knows that 10.0.0.5 is
contained only within record 2.

I can't seem to figure out the correct syntax to make this type of query
happen. Any help would greatly

Be appreciated.

 

Devin Atencio

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Datatype Inet and Searching
@ 2003-12-03 18:02  Gaetano Mendola <mendola@bigfoot.com>
  parent: Devin Atencio <devin@burgoyne.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Gaetano Mendola @ 2003-12-03 18:02 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Devin Atencio <devin@burgoyne.com>

Devin Atencio wrote:
>  
> 
> Dear Users,
> 
>  
> 
> I am very new to using the inet data type and I have a database with a 
> list of CIDRs in it
> 
> And I was hoping to be able to do some kind of select statement that 
> would pull the record
> 
> That the IP given is located in for example. If in my database I have a 
> record like:
> 
>  
> 
> Id          cidr                   name
> 
> 1          10.0.0.0/30        user1
> 
> 2          10.0.0.4/30        user2
> 
> 3          10.0.0.8/30        user3
> 
>  
> 
> I was hoping to be able to do something like:
> 
> Select * from mytable where cidr <<=’10.0.0.5’


select * from mytable where cider >>= '10.0.0.5'

The operation a >>= b mean:

a contain or is equal b.



Regards
Gaetano Mendola





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Datatype Inet and Searching
@ 2003-12-03 18:32  Guy Fraser <guy@incentre.net>
  parent: Devin Atencio <devin@burgoyne.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Guy Fraser @ 2003-12-03 18:32 UTC (permalink / raw)
  To: pgsql-sql



Devin Atencio wrote:

> Dear Users,
>
> I am very new to using the inet data type and I have a database with a 
> list of CIDRs in it
>
> And I was hoping to be able to do some kind of select statement that 
> would pull the record
>
> That the IP given is located in for example. If in my database I have 
> a record like:
>
> Id cidr name
>
> 1 10.0.0.0/30 user1
>
> 2 10.0.0.4/30 user2
>
> 3 10.0.0.8/30 user3
>
> I was hoping to be able to do something like:
>
> Select * from mytable where cidr <<=’10.0.0.5’
>
> And the database would return only record 2 since it knows that 
> 10.0.0.5 is contained only within record 2.
>
> I can’t seem to figure out the correct syntax to make this type of 
> query happen. Any help would greatly
>
> Be appreciated.
>
> Devin Atencio
>
Select * from mytable where cidr >>= ’10.0.0.5’

or

Select * from mytable where ’10.0.0.5' <<= cidr

-- 
Guy Fraser
Network Administrator
The Internet Centre
780-450-6787 , 1-888-450-6787

There is a fine line between genius and lunacy, fear not, walk the
line with pride. Not all things will end up as you wanted, but you
will certainly discover things the meek and timid will miss out on.







^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-12-03 18:32 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-12-02 23:50 Datatype Inet and Searching Devin Atencio <devin@burgoyne.com>
2003-12-03 18:02 ` Gaetano Mendola <mendola@bigfoot.com>
2003-12-03 18:32 ` Guy Fraser <guy@incentre.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox