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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:33:02+00:00 2026-06-12T22:33:02+00:00

Struggling with a SQL query of mine here. I have a table: APPS(id, game)

  • 0

Struggling with a SQL query of mine here.
I have a table:

APPS(id, game)
Where id is the primary key.

What I was trying to do is show all the id’s who use at least all the games that the person with the id “Tim” does.
I have a query that works, and returns what i need it to, but i cobbled it together from forums.
So what I’d really like is a quick and basic rundown of how the query works. Heavy detail isn’t necessary, as i understand most of the terminology, but just what the query does, and how it determines the correct records.

My query is:

SELECT id
FROM APPS X
WHERE NOT EXISTS
     (SELECT *
      FROM APPS Y
      WHERE id='Tim' AND NOT EXISTS
           (SELECT *
            FROM APPS Z
            WHERE Z.id = A.id AND Z.id = Y.id));

Thank you so much for any help!

Edit: The query works fine, but what i was after is how it works and how it returns the records it does.

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

    The query works fine, but what i was after is how it works and how it
    returns the records it does.

    Right, so you’ve hit the problem called Relational Division. Joe Celko has written a good article about that.

    The query that you posted is really strange:

    WHERE Z.id = A.id AND Z.id = Y.id
    

    In relational division, the innermost not exists query has two equality statements for different columns. For example, from Joe Celko’s post:

    WHERE (PS1.pilot_name = PS2.pilot_name)
          AND (PS2.plane_name = Hangar.plane_name)
    

    Comparing pilot_name and plane_name makes sense, where comparing id twice makes no sense at all.

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

Sidebar

Related Questions

I have a table (TableA) where the primary key exists as a foreign key
I'm struggling with some SQL/php syntax issues here. I'm trying to write two functions.
I am struggling to come up with the SQL query to find the all
I've got an SQL query that returns all the rows in one table (country)
I'm really struggling with this query. I have 4 tables (http://oberto.co.nz/db-sql.png): Invoice_Payement, Invoice, Client
I'm struggling with correct procedure for executing SQL query. Basically, I have text field
i have a simple SQL query, but im struggling to replicate in LINQ select
Please explain the SQL query given below. I m new with SQL and struggling
I am struggling to convert this sql query SELECT feature.*, rolefeature.roleId, rolefeature.permission FROM feature
I have the following SQL query: select AuditStatusId from dbo.ABC_AuditStatus where coalesce(AuditFrequency, 0) <>

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.