coast917 Posted March 5, 2007 Share Posted March 5, 2007 Example: I have a table called "discounts" that looks like this: Total Discount 100 5% 200 7% 300 10% The way it should work is that if someone buys something between 100-199, they'd get the 5% discount, 200-299, the 7% etc. My question is how to I do this without having to have a range-start and range-end field? I just want to store the range start. I know I could do this easily by doing something like: $total would be a variable amount SELECT discount FROM discounts WHERE $total >= total ORDER BY total DESC LIMIT 1 That seems like a hack for some reason. Is there a more "proper" way to do this. Quote Link to comment https://forums.phpfreaks.com/topic/41332-help-with-query-ranges/ Share on other sites More sharing options...
artacus Posted March 5, 2007 Share Posted March 5, 2007 That's the best you're going to do, because you don't have all of the data you need in 1 row. Quote Link to comment https://forums.phpfreaks.com/topic/41332-help-with-query-ranges/#findComment-200294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.