Friday, March 9, 2012

Obvious Newbile Question--How do I create a variable within SQL?

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 which posts to itself.

SQL 7, ASP Javascripting goin' on.

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))

Can anyone help with this?
Thanks,Are you using a recordset object in your asp code to loop through to create the options ? Since you have a form that posts to itself, you can use that to pass the id that you need to populate the listbox - that loops through the recordset.

No comments:

Post a Comment