Range of Numbers

1. Senior Member
Join Date
Dec 1969
Posts
135

## Range of Numbers

Hello all..<BR><BR> If I have a table with a list of numbers... say 1-100, and I have a search script on it.. How can I search a range of numbers? Say I want some type of error control like +/- 5...whereas, if a user searches on the number 20, it will return all records with the numbers 15 through 25.

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## In SQL?

&#060;%<BR>...<BR>num = CLng( Request("theNumber") )<BR>SQL = "SELECT * FROM table WHERE someField BETWEEN " & (num-5) & " AND " & (num+5)<BR>...<BR>%&#062;<BR>

3. Senior Member
Join Date
Dec 1969
Posts
135

## What is CLng?? (nt)

.

4. Senior Member
Join Date
Dec 1969
Posts
1,570

## RE: What is CLng?? (nt)

puts the string into a long number format...

5. Senior Member
Join Date
Dec 1969
Posts
10,852

## RE: What is CLng?? (nt)

Convert to Long Integer(4 Byte)

6. Senior Member
Join Date
Dec 1969
Posts
135

## Still get an error...

That expression didn&#039;t work.. It tells me I have an error in FOM clause..<BR><BR>SELECT * FROM fieldname BETWEEN 40 and 50.. is my SQl statement an dI still get an error.

7. Senior Member
Join Date
Dec 1969
Posts
1,570

## need to put the between in the where statement....

SELECT * <BR>FROM fieldname <BR>WHERE num BETWEEN 40 and 50

8. Senior Member
Join Date
Dec 1969
Posts
10,852

## No no no...

SEELECT * FROM TableName WHERE fieldName BETWEEN....<BR><BR>Note teh *tablename*...*NOT* the fieldname...

9. Senior Member
Join Date
Dec 1969
Posts
1,570

## you're right...

I was just copying and pasting to fast from his post...<BR><BR>The point should&#039;ve been acknowledged still!!!

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## Didn't do what I showed...

Xander is right, but so was my first post.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•