Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post

    Select data between values.

    i wanna select data between 2 prices. What mysql syntax code i'd use?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,436
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Code:
    SELECT * FROM table WHERE price BETWEEN 13 AND 27
    ??? is that what you mean?

    CAUTION: BETWEEN is *inclusive*. So both 13 and 27 would be found with that code. If you wanted greater than 13 and less than 27 (e.g., 13.01 to 26.99) the best thing to do would be to use two separate comparisons:
    Code:
    SELECT * FROM table WHERE price > 13 AND price < 27
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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