I'm working in MySQL with PHP. I'm doing a query for a zip code from one table which contains the zip codes and the lat/lon for each zip code. The second table contains the zip code and average income for that zip code. The user gives a zip code (let's call this the base zip code) and it returns a 15 mile radius of zip codes. Via the web page the user can query with a range of incomes that uses a BETWEEN for MySQL in PHP.
My problem is, depending on what range the user selects, their base zip code might not appear all the time because it's outside of the income ranges. When this happens it is confusing to the user because the sorted output doesn't include their base zip code. I want to be able to include the base zip code as if there was no income range specified.
How can I include the ranged data (that uses the BETWEEN) and include the base zip code's data so it still takes advantage of MySQL's ORDERing of the output. Thanks!
UPDATE: Here is the working quer