Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    4

    Unanswered: Querying for items NOT entered...

    I'm making an online Quiz and I have a table with a list of Category names associated with CategoryIDs that remains static.
    Another table collects data associated with these categories, and in addition to the data, contains the CategoryID for the data.

    I want to populate the select options of a drop down menu with the Categories NOT YET ENTERED for a specific Quiz. I have a form with posts to itself.

    Can anyone help me?
    Thanks

  2. #2
    Join Date
    Jan 2003
    Posts
    4

    Re: Querying for items NOT entered...

    Oops, forgot to mention...SQL 7, ASP Javascript.

  3. #3
    Join Date
    Sep 2002
    Location
    Kyiv, Ukraine
    Posts
    77
    Ok, you have one table "Categories" with following fields: CategoryID and CategroyName. You have another table "Data" with fields: SomeData and CategoryID ...

    If you want to insert into drop-down list only those CategoryName-s which CategoryID-s are not yet entered in table "Data" (with appropriate SomeData) than the following query should return the needed recordset with all not enetered in Data category names:
    Code:
    SELECT Categories.CategoryName 
    FROM Categories RIGHT JOIN Data ON Categories.CategoryID = Data.CategoryID;
    Yours faithfully,
    Yaroslav Zaremba

  4. #4
    Join Date
    Jan 2003
    Posts
    4
    aZa,

    Thanks for your reply..RIGHT JOIN returns only those CategoryNames and CategoryID's already entered when I filter for a specific, in this case, Case Study, thusly:

    SELECT tblDetailCaseStudyCategory.intDetailCaseStudyCateg oryID,
    tblDetailCaseStudyCategory.strCaseStudyCategory
    FROM tblDetailCaseStudyCategory RIGHT OUTER JOIN
    tblCaseStudyData ON
    tblDetailCaseStudyCategory.intDetailCaseStudyCateg oryID = tblCaseStudyData.intCaseStudyCategory
    WHERE (tblCaseStudyData.intCaseStudyID = 69)

    I did some more looking around yesterday and came up with something that works, I just have to determine how to create a variable in SQL and then pass the CaseStudyID from an ASP page...

    SELECT DISTINCT
    tblDetailCaseStudyCategory.intDetailCaseStudyCateg oryID,
    tblDetailCaseStudyCategory.strCaseStudyCategory
    FROM tblDetailCaseStudyCategory, tblCaseStudyData
    WHERE (tblDetailCaseStudyCategory.intDetailCaseStudyCate goryID NOT
    IN
    (SELECT intCaseStudyCategory
    FROM tblCaseStudyData
    WHERE intCaseStudyID = 69))


    Thanks again,



    Originally posted by aZa
    Ok, you have one table "Categories" with following fields: CategoryID and CategroyName. You have another table "Data" with fields: SomeData and CategoryID ...

    If you want to insert into drop-down list only those CategoryName-s which CategoryID-s are not yet entered in table "Data" (with appropriate SomeData) than the following query should return the needed recordset with all not enetered in Data category names:
    Code:
    SELECT Categories.CategoryName 
    FROM Categories RIGHT JOIN Data ON Categories.CategoryID = Data.CategoryID;

Posting Permissions

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