I’m trying to figure out how to select 3 adjacent rows from a table with a price < current item price. The problem is that if I’m selecting the first, second, or third row in the table, I need to select three adjacent rows around the current item. Emphasis needs to be put on the lower price items, for example, if I’m selecting the third row from the table, I need to select the first two rows and the fourth row. Here is my query so far:
SELECT * FROM (SELECT * FROM temp_db_cart WHERE airport='$airport' AND people='$people' AND price < '$price' ORDER BY price DESC LIMIT 3 ) ORDER BY price ASC LIMIT 3
PHP/MySQL combination can be used for an answer. Any help would be appreciated.