SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2008
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding the problems a student didn't do

    How do I find the problems that the student didn't do? i.e. the rows problem rows that (for this particular student) doesn't have a matching row in personproblem.

    My (wrong) idea was:

    Code:
    SELECT problem.id, problem.name 
    FROM problem 
    LEFT OUTER JOIN personproblem ON personproblem.problem = problem.id 
    WHERE personproblem.id IS NULL 
     AND (personproblem.person = " . $studentid . " OR personproblem.person IS NULL)
    My problem is that if another student have made this problem, it will not show up.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,340
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you were so close
    Code:
    SELECT problem.id
         , problem.name 
      FROM problem 
    LEFT OUTER 
      JOIN personproblem 
        ON personproblem.problem = problem.id 
       AND personproblem.person = " . $studentid . " 
     WHERE personproblem.id IS NULL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    May 2008
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that helped!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •