Selecting closet numbers in a MySQL Database
Posted: Sun Feb 01, 2009 7:13 pm
I can't seem to get my head around this problem...
Let's say I have a postcode search where you can enter your postcode and search a MySQL Database. I want to be able to pull out the 6 closet postcodes to the postcode searched for...
What query would I have to run for this? I was thinking something like the below query but I don't think it would work because it would pull out practically any number not just the closet:
I can't really use ORDER BY postcode asc because i need to search numbers less than the postcode and numbers greater than the postcode.
Anyone have any ideas for me?
Let's say I have a postcode search where you can enter your postcode and search a MySQL Database. I want to be able to pull out the 6 closet postcodes to the postcode searched for...
What query would I have to run for this? I was thinking something like the below query but I don't think it would work because it would pull out practically any number not just the closet:
Code: Select all
SELECT * FROM postcodes WHERE postcode='4213' or postcode<='4213' or postcode>='4213' LIMIT 10Anyone have any ideas for me?