SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Mysql query help

    Hello all,
    Attached along with this post is a sample of data contained on a table containing price ranges. I need help on determining the correct price range for any user inputted value.

    For example, if the user enters 250 as price, the query would return the single row of data containing label "$100 to $500". Likewise, if 1380 is entered as price, the query would return the single row of data containing label "$501 to $1500" etc.
    Attached Images Attached Images

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    SELECT label
      FROM daTable
     WHERE $user_entered_price 
           BETWEEN lower_range AND upper_range
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you r937, it worked like a charm


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •