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

  • SEARCH
  • Home
  • 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 8637381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:27:58+00:00 2026-06-12T10:27:58+00:00

Besides the question above I’d like to know if there is any way to

  • 0

Besides the question above I’d like to know if there is any way to optimize this MySQL statement.

SELECT *
FROM `products`
WHERE
  `category` = 3073 OR
  `category` = 3074 OR
  `category` = 3100 OR
  `category` = 3102 OR
  `category` = 3106 OR
  `category` = 3109 OR
  `category` = 3111 OR
  `category` = 3115 OR
  `category` = 3130 OR
  `category` = 3134 OR
  `category` = 3144 OR
  `category` = 3146 OR
  `category` = 3152 OR
  `category` = 3157 OR
  `category` = 3162 OR
  `category` = 3163 OR
  `category` = 3164 OR
  `category` = 3166 OR
  `category` = 3167 OR
  `category` = 3168 OR
  `category` = 3170 OR
  `category` = 3171 OR
  `category` = 3177 OR
  `category` = 3181 OR
  `category` = 3182 OR
  `category` = 3184 OR
  `category` = 3190 OR
  `category` = 3191 OR
  `category` = 3192 OR
  `category` = 3213 OR
  `category` = 3224 OR
  `category` = 3227 OR
  `category` = 3228 OR
  `category` = 3235 OR
  `category` = 3238 OR
  `category` = 3239 OR
  `category` = 3240 OR
  `category` = 3244 OR
  `category` = 3245 OR
  `category` = 3246 AND
  `active` = 1 AND
  `price_notax` > 0 AND
  `deleted` = 0
ORDER BY `position` ASC
LIMIT 0, 24;

This statement is also displaying the products which have field value of price_notax equal to 0, why? I stated the number need to be higher than 0…

Any help would be appreciated.

  • 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-12T10:27:59+00:00Added an answer on June 12, 2026 at 10:27 am

    When that WHERE clause is evaluated, any of the ORed clauses being true will make the state of the AND clauses irrelevant. To correct this you must surround the set of OR clauses with parentheses so they are evaluated separately…

    But to accomplish the same thing with greater readability, use an IN clause, instead:

    SELECT * 
    FROM products 
    WHERE category IN (3073, 3074, 3100, 3102, 3106, 3109, 3111, 3115, 3130, 3134, 3144, 3146, 3152, 3157, 3162, 3163, 3164, 3166, 3167, 3168, 3170, 3171, 3177, 3181, 3182, 3184, 3190, 3191, 3192, 3213, 3224, 3227, 3228, 3235, 3238, 3239, 3240, 3244, 3245, 3246) 
    AND active = 1 
    AND price_notax > 0 
    AND deleted = 0 
    ORDER BY position ASC LIMIT 0, 24;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Besides readability is there any significant benifit to using a CASE WHEN statement vs
Maybe this is a silly question but is there a difference,besides the obvious,between android:text=@string/....
Besides a drag-and-drop UI designer are there any other missing features when developing for
I know this question has been asked before, but despite being a fairly experienced
I am seeking a way in mySQL to select only records that have corresponding
Besides the obvious case of treating different exceptions differently, is there any benefit in
Besides what it comes with in 2.0 (the generated aspnetdb.mdf), is there a standard
Besides the existence of Smarty.class.php (which is also arguable), how do we know that
Which other languages besides English does Levenshtein distance support its implementation? I know that
This question has one major question, and one minor question. I believe I am

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.