I have a table with from_value and to_value... I want to return the results where value X is between from_value and to_value...
so I will have a value such as 25... then I want to select which record it is associated to based on the from_value and to_value values in the DB...
Any idea how I can do that? It's probably dead simple.. but I'm not getting it... thanks!
Getting value between two values in DB
Moderator: General Moderators
Sure, so I have a table like this
id
name
from_value
to_value
Then I have a quiz with 5 questions and 5 options per question... each option is worth a certain value... The values of each is totaled and I want to return the row from the above table where that value is in between the from_value and to_value
id
name
from_value
to_value
Then I have a quiz with 5 questions and 5 options per question... each option is worth a certain value... The values of each is totaled and I want to return the row from the above table where that value is in between the from_value and to_value
GeXus wrote:Sure, so I have a table like this
id
name
from_value
to_value
Then I have a quiz with 5 questions and 5 options per question... each option is worth a certain value... The values of each is totaled and I want to return the row from the above table where that value is in between the from_value and to_value
Code: Select all
SELECT * FROM [tablename] WHERE $myvalue >= `from_value` AND $myvalue <= `to_value`