SELECT -/+ Number

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
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

SELECT -/+ Number

Post by mikeeeeeeey »

What SQL do I use to see if a number is within plus or minus a number?

Say -/+ 10 with 10 as the start point

Would retrive: 7,13,1

but not: 21, -5


???

Thanks in advance
Last edited by mikeeeeeeey on Tue Jan 15, 2008 6:48 am, edited 2 times in total.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: SELECT -/+ Number

Post by VladSun »

[sql]SELECT a FROM TABLE WHERE a BETWEEN $start_point - $interval AND $start_point + $interval[/sql]
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
mikeeeeeeey
Forum Contributor
Posts: 130
Joined: Mon Jul 03, 2006 4:17 am
Location: Huddersfield, UK

Re: SELECT -/+ Number

Post by mikeeeeeeey »

Thanks, it seems really silly now I think about it. ah well

Is there any way do something similar to explode() in SQL?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: SELECT -/+ Number

Post by VladSun »

The closest one I am to able find is http://dev.mysql.com/doc/refman/5.0/en/ ... nction_elt
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply