I have a table setup similar to the below:
CREATE table TABLE_prices
(
PRICE_ID int unsigned not null auto_increment primary key,
RANGE1_START int,
RANGE1_END int,
RANGE1_PRICE decimal(10,2),
RANGE2_START int,
RANGE2_END int,
RANGE2_PRICE decimal(10,2),
RANGE3_START int,
RANGE3_END int,
RANGE3_PRICE decimal(10,2)
);
If I have a value (100 as an example), is there a way to build a select statement to get the RANGE#_PRICE based on which range the value falls in?
My instinct is that I’m probably going to have to extract the range data from MySQL and the iterate through it in PHP but I didn’t know if there was a way to cut right to it with MySQL.
Thank you!
I don’t know what you are trying to achieve but you can do it in single statement: