O.P. RE: Mysql Help
Thats why you do the order by diff.
Notes are in { }
SELECT discountstandard.* {< selects all the fields from the table}, ABS(quantity - <your value>) {<Creates a positive value from the data in the DB - the value you are looking for. This gives you the distance between the value in the DB and the value you want to find} AS diff {places the value into a psudeo column} FROM discountstandard {The table} ORDER BY diff {Sorting by the distance from your desired number} ASC LIMIT 5
Does that make sense?
"A towel is about the most massively useful
thing an interstellar hitchhiker can have."
|