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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:22:59+00:00 2026-06-08T01:22:59+00:00

I have a SELECT query across 2 tables that isn’t returning any results and

  • 0

I have a SELECT query across 2 tables that isn’t returning any results and I have no idea why it isn’t. This is the query that doesn’t return any rows:

SELECT b.name, b.description, b.badge_id 
FROM badges AS b 
WHERE b.type = 'have' AND b.brand_id = 'zTR7wH5FMl' AND ISNULL(b.series_id) AND b.amount <= 89 
AND NOT EXISTS (SELECT date_earned 
                FROM users_badges AS ub 
                WHERE ub.user_id = 'fMcBBx' AND ub.badge_id = b.badge_id)

If I just take off the AND NOT EXISTS clause at the end to check that they haven’t already earned the badge I get these results back:

name            description                                             badge_id
Baker's Dozen   Add 13 items to your Johnny Cupcakes shelf.             sdfKHJkun7
Cupcaker        Have 82 items on your Johnny Cupcakes shelf.            4MeoheBdik
Freshly Baked   Have your first item on your Johnny Cupcakes shelf...   kdJGH98NdI

Which is exactly what I expect to get. The AND NOT EXISTS check is the only difference. There is no data in the users_badges table yet, so I don’t see why it would be returning false. It seems to me that it would be incapable of returning false. Why would it be invalidating the entire query?

  • 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-08T01:23:01+00:00Added an answer on June 8, 2026 at 1:23 am

    Adding a row to the table seems to have solved it. I guess if the table is empty SQL doesn’t even check the EXISTS condition and always returns false because there is no way the row could exist in the table.

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

Sidebar

Related Questions

I have a SELECT query that I am expecting millions of results from. I
Dear all, I have a select query that currently produces the following results: DoctorName
I have come across a query like this in a database: SELECT col_a FROM
I'm coming across this situation alot, I'll have a query that will have one
I have a select query in mysql . On each execution of this query
I have a select query. I want to replace that select query with another
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
i have this query: SELECT `completed`.`ID` AS `ID`,`completed`.`level` AS `level`,`completed`.`completed_in` AS `completed_in`, COUNT(1) AS
I have this query SELECT zip, ( 3959 * acos( cos( radians(34.12520) ) *
I have the following query in mysql 5.1.41: select distinct table_schema from information_schema.tables where

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.