Search a range given a numer?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
alwoodman
Forum Newbie
Posts: 6
Joined: Thu Oct 07, 2004 3:59 pm
Location: Swansea

Search a range given a numer?

Post by alwoodman »

I am looking to seach a given range when presented with a single number. For example if I have the wind speed of 10 then need to query for range 5-15 (i.e. 10 +-5) within the database, anyone any ideas how'd I'd dynamically do this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Guessing MySQL: BETWEEN syntax.

Code: Select all

SELECT * FROM table WHERE field BETWEEN {$speed}-5 AND {$speed}+5
Post Reply