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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:17:19+00:00 2026-06-08T12:17:19+00:00

I have a query that doesn’t work. I’ve fixed the problem by using a

  • 0

I have a query that doesn’t work. I’ve fixed the problem by using a single IN statement (the library I’m using to construct my queries was causing this to happen) but I’m still curious why this happens.

The query is as follows:

SELECT * FROM (`table`) 
WHERE     `field` = 'false' 
      AND `something` LIKE '%string%' 
      AND `status_id` IN ('1') 
      OR `status_id` IN ('2') 
      OR `status_id` IN ('3') 

The query to me makes sense: Select everything from the table where field = false and something is like string and status id is in 1 or status id is in 2 or status id is in 3

When there are multiple IN statements the LIKE portion of the query is completely ignored.

Any ideas why mutliple IN statements would cause the LIKE to be ignored? I can’t work out why: re-arranging the query has no affect (moving the LIKE to the end vs. the start)

  • 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-08T12:17:20+00:00Added an answer on June 8, 2026 at 12:17 pm

    Precendence? Shouldn’t you use brackets to differentiate the AND and OR? status_id IN (‘x’) will if true cause the rest of the expression to be ignored.

    SELECT * FROM (`table`) 
    WHERE     `field` = 'false' 
          AND `something` LIKE '%string%' 
          AND (`status_id` IN ('1') 
                OR `status_id` IN ('2') 
                OR `status_id` IN ('3') 
          )
    

    which is the same as

    SELECT * FROM (`table`) 
    WHERE     `field` = 'false' 
          AND `something` LIKE '%string%' 
          AND `status_id` IN ('1', '2', '3')
    

    Try it for yourself by seeing what comes out with this.

    SELECT * FROM (`table`) 
    WHERE     `field` = 'false' 
          AND `something` LIKE '%string%' 
          AND `status_id` IN ('1') 
          OR 1=1    
    

    Ask yourself what this query should return

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

Sidebar

Related Questions

I have a query that works on MySQL but doesn't work on Oracle, and
i have some problems with a Query seem IN dosen't work with Group_concat, that
I am using in C# MYsql .I have query that works if I run
Say I have 3 queries. Query 1 returns a piece of information that Query
i have a query that doesn't seem to be executing for some reason. I've
I have a query problem. I have a table of agents that do things.
I have a query that does what i want joining table but i need
Right now I have a PHP file that does a MYSQL query and then
I have a query that successfully grabs the unique products from my products table
I have a query that basically combines tables of actions and selects from them

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.