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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:26:26+00:00 2026-06-09T23:26:26+00:00

It seems I’m getting an impossible WHERE on a SELECT query. I’ve posted two

  • 0

It seems I’m getting an “impossible WHERE” on a SELECT query. I’ve posted two queries below, which differentiate in the subquery. What these queries do is check to see if a user has saved something once before, before updating a count. I am using SELECT for testing purposes, but the actual query would be using UPDATE:

UPDATE articles SET article_count = article_count+1 
WHERE id = 2343243 AND (
    SELECT COUNT(*) 
    FROM posts as p
    WHERE p.post_id = 2343243 AND p.user_id = 3
) = 1;

The following two queries are what I’m using to test to see if the data is in the table (for testing only):

EXPLAIN 
SELECT a.id 
FROM articles as a 
WHERE a.id = 2343243 AND (
    SELECT COUNT(*) 
    FROM posts as p
    WHERE p.post_id = a.id AND p.user_id = 3
) = 1;

Query 1 returns Impossible WHERE in EXPLAIN.
The select_type of the query #2 is SUBQUERY.

EXPLAIN 
SELECT a.id 
FROM articles as a 
WHERE a.id = 2343243 AND (
    SELECT COUNT(*) 
    FROM posts as p
    WHERE p.post_id = 2343243 AND p.user_id = 3
) = 1;

Query 2 returns Impossible WHERE noticed after reading const tables in EXPLAIN.
The select_type of the Query 2 is DEPENDENT SUBQUERY.

Question: Any ideas on how to make this not an impossible WHERE query? And also, which would be faster?

  • 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-09T23:26:27+00:00Added an answer on June 9, 2026 at 11:26 pm

    After reading on Mysql.com about Impossible WHERE, it isn’t really a good idea to work with such a constraint as WHERE 1 = 1 in a query:

    Because it is never possible for this condition to be true, the
    EXPLAIN statement will show the words Impossible WHERE. Informally, we
    at MySQL say that the WHERE has been optimized away.

    Mysql.com: http://dev.mysql.com/doc/internals/en/optimizer-eliminating-dead-code.html

    I’ve decided to ditch that query for a new query I’ve written that utilizes indexes for both the main query and the subquery which is a faster solution and seemingly less complex:

    UPDATE articles 
    SET article_count = IF (
        (SELECT count(*) FROM posts WHERE post_id = 2343243 AND user_id = 3) = 1, article_count+1, article_count) 
    WHERE id = 2343243;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems fairly straight forward and simple, I am doing the following and getting an
Seems like everything worked fine when I pushed to Heroku as shown below. Then
Seems like everyone always ignores the time part, but how would you compare two
I'm trying to select an H1 element which is the second-child in its group
Seems begineer but i really do not understand what these lines of code saying,
Seems they both let you retrieve the minimum, which is what I need for
Seems like there are two products with similar names, but isn't what I expect.
Seems like MySQL Bug; Request: SELECT * FROM table WHERE ( id LIKE '%тест
Seems to be a problem that many people have, but all the answers I
Seems that This will be an easy question for you but this problem is

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.