I am developing a real estate script. The script has a search option where an user can specify the price range eg. user_price_low to user_price_high and the listings have to be fetched from a database, which has eg. db_price_high and db_price_low.
I used a BETWEEN statement trying to find the matches,
WHERE price_low BETWEEN '.$_REQUEST['minprice_buy'].' AND '.$_REQUEST['maxprice_buy']
but to my surprise...
If an user has user_price_high = 60 and user_price_low = 20 AND the record has db_price_low = 30 and db_price_high = 120
my query is invalid in this case.
i tried looking at MySql Query- Date Range within a Date Range but does that match what I want?