range of values

R

raj

Hi,

The business scenaraio is i have table called rules in that rules
table i have a column (varchar()) which has the value
IP > 182.168.0.1 and IP < 182.168.0.10 .

i had witten a sql query for getting this value.so i have this value
IP > 182.168.0.1 and IP < 182.168.0.10 with me.

i need to write an expression in java such that my input value assume
to be 182.168.0.6 .

i need to find that my value lies in that range .

any one help me out thanks in advance.
 
D

derek

Hi,
The business scenaraio is i have table called rules in that rules
table i have a column (varchar()) which has the value
IP > 182.168.0.1 and IP < 182.168.0.10 .
i had witten a sql query for getting this value.so i have this value
IP > 182.168.0.1 and IP < 182.168.0.10 with me.
i need to write an expression in java such that my input value assume
to be 182.168.0.6 .
i need to find that my value lies in that range .
any one help me out thanks in advance.

Not sure exactly what you are trying to do.
I am guessing you have an ip address that you want to use in a query and see if it is between some range of ip numbers.
Instead of using a single field that is varchar, you should use two fields defined as unsigned longs.
If you store the ip address data as unsigned longs in the database, it will be simple enough then to compare it using something like

where ipnum >= iplow and ipnum <= iphigh



=====================================================
THIS IS MY SIGNATURE. There are many like it, but this one is mine.
 
R

Roedy Green

where ipnum >= iplow and ipnum <= iphigh

in Java I like to write that as:

if ( iplow <= ipnum && ipnum <= iphigh )

because it more closely mimics the mathematical notation:

iplow <= ipnum <= iphigh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top