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 7938153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:43:33+00:00 2026-06-03T22:43:33+00:00

I am stuck on range search query. Please see this below examples : SELECT

  • 0

I am stuck on range search query. Please see this below examples :

SELECT * FROM product where status='A' and subcat_id=5 AND product.price < 50 AND  product.price BETWEEN 50 AND 100 AND category = "male"

In above example , it does not returns records below 50 yet they are in database.

If I try as in second example below :

SELECT * FROM product where status='A' and subcat_id=5 AND product.price < 50 OR  product.price BETWEEN 50 AND 100 AND category = "male"

It returns all records which not under male category but less then 50

Finally I want to get records which are in range less then 50 or between 50 to 100 but only for male category.

Thanks for your advice.

  • 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-03T22:43:35+00:00Added an answer on June 3, 2026 at 10:43 pm

    AND has higher precedence than OR. Your query is interpreted as follows:

    SELECT col1, col2, ..., coln
    FROM product
    WHERE (status='A' AND subcat_id=5 AND product.price < 50) OR
          (product.price BETWEEN 50 AND 100 AND category = 'male')
    

    You need to insert parentheses in the appropriate place to group the terms correctly. The only remaining question is precisely where to put them.

    I think you mean this:

    SELECT col1, col2, ..., coln
    FROM product
    WHERE status='A'
    AND subcat_id=5
    AND (
        product.price < 50 OR 
        (product.price BETWEEN 50 AND 100 AND category = 'male')
    )
    

    This will show products under 50 for all categories, and products between 50 and 100 for the category male.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im stuck with this little project in C# but basically my problem is this:
I have no experience when it comes to this type of query and i'm
im sort of stuck on how to populate a combobox with a range of
I am completely stuck with this: I start out with a flat file type
I am slightly stuck on the javascript logic to accomplish this. Basically If I
I'm stuck with a problem of the python wrapper for OpenCv. I have this
i am suppose to solve this question but i am stuck. Write a program
In a report generator I wrote the user can select a date range to
I am trying to extract a range of pages from a multipage pdf file
I'm kinda stuck with this task. I have a macro that retrieve two ranges

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.