Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:55:19+00:00 2026-06-17T20:55:19+00:00

I have a table setup similar to the below: CREATE table TABLE_prices ( PRICE_ID

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:55:21+00:00Added an answer on June 17, 2026 at 8:55 pm

    I don’t know what you are trying to achieve but you can do it in single statement:

    $price = 100;
    
    $sql = "
    (
      SELECT 1 as range, price_id, range1_start as range_start, range1_end as range_end FROM table_prices WHERE range1_start >= $price AND range1_end <= $price
    ) UNION
    (
      SELECT 2 as range, price_id, range2_start as range_start, range2_end as range_end FROM table_prices WHERE range2_start >= $price AND range2_end <= $price
    ) UNION
    (
      SELECT 3 as range, price_id, range3_start as range_start, range3_end as range_end FROM table_prices WHERE range3_start >= $price AND range3_end <= $price
    )";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a setup similar to this: Table1 id1 (int) name (varchar) Table 2
I have a standard jQuery autocomplete setup similar to the below: $(input#autocomplete).autocomplete({ source: source,
I have table with Names such as JS Engineering Services$Web User Setup Header and
I have the following setup: Table: Question QuestionId Table: QuestionTag QuestionId TagId Table: Tag
I have created a GUI that will setup the pivot table. For example, I
I have the following setup in MS IE8: <table class=my-info> <tbody> <tr> <td class=info-left>First
Here's my toy setup. I have 3 tables. One table is a guest list
I am trying to create a table view similar to the YouTube video uploader
My problem is similar to: Problem creating NSManagedObject derived class I have setup a
I am looking for some, I have the following table setup in my test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.