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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:01:06+00:00 2026-06-02T16:01:06+00:00

I have this code in Access: SELECT DISTINCT p.course, p.date FROM Student s, Participation

  • 0

I have this code in Access:

SELECT DISTINCT p.course, p.date
FROM Student s, Participation p
WHERE s.id = d.student AND footballer = NO

When I run it, I get 10 rows. So I use it as a subquery the next time:

SELECT c.course, c.date
FROM Course c
WHERE NOT EXISTS
(SELECT DISTINCT p.course, p.date
FROM Student s, Participation p
WHERE s.id = d.student AND footballer = NO)

and I get no results at all. So I remove the NOT in NOT EXISTS and I get all 15 rows that are in the Course table. So it seems to me that course and date from the subquery read from Course from the main query instead of from Participation from the subquery. But how is this possible since I have created different alias names and even the source tables are different (though they both contain columns with names course and date) and how do I solve the problem?

  • 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-02T16:01:07+00:00Added an answer on June 2, 2026 at 4:01 pm

    Your sub-query is not related to the main query. Try something like this?

    SELECT c.course, c.date
      FROM Course c
     WHERE NOT EXISTS (
                       SELECT DISTINCT p.course, p.date
                         FROM Student s INNER JOIN Participation p ON s.id = d.student
                        WHERE footballer = NO
                          AND p.course = c.course
                          AND p.date   = c.date
                      )
    

    This now takes every record in Course and runs the NOT EXISTS check for each row, filtering the Participation table by the course and date fields.

    Your example just ran the sub query once. It returned 10 records, and so the NOT EXISTS always failed.

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

Sidebar

Related Questions

I have this code to get the local date/time. It works but it seems
i have this php code: $query = mysql_query(SELECT * FROM table WHERE id=$id); while($item
I have a query to return random distinct rows from an Access database. Here
I have this code: $query = select id from votes where username = '$user'
If I have this code (which is from their docs) $query = DB::query(Database::SELECT, 'SELECT
i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() {
I have used code like this: http://msdn.microsoft.com/en-us/library/dw70f090.aspx to access database before when working in
Possible Duplicate: How Do I Access This Variable? Lets say I have the code:
I have this code, the idea is to read from a file and the
I have this error with an sqlite-related cursor. i subclass SQLiteOpenHelper to get access

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.