I have the following Table in my SQL Server 2008 database
dbo.FormEmployment
------------------
employmentID int (PK)
formID int (FK)
gradeID int
employerName nvarchar
I wish to create a query that will select all Users based on their gradeID. At the moment I have the following query
DECLARE @gradeID int
SET @gradeID = 1
SELECT distinct u.userID, u.userTypeID, u.firstName, u.lastName, u.email, u.password, u.contactNumber, u.organisationID, u.emailVerificationCode, u.mobileVerificationCode, u.userStatusID
FROM [User] u, dbo.FormEmployment emp, dbo.Form f
WHERE u.userTypeID = 47
--Grades
AND emp.gradeID = @gradeID
AND f.formID = emp.formID
AND f.locumID = u.userID
The above query allows me to state a single gradeID and then get all Users who match that gradeID. However, I also need to be able to state several gradeIDs, for example, I would like for my parameter, @gradeID, to be like this
SET @gradeID = 1, 2, 3
So that it would get all the Users who have grades 1, 2 or 3.
Is there anyway of doing this? Any help or guidance with this would be greatly appreciated as the search I have to build for an application relies on it.
Thanks.
Edit
More information about how the search will work.
Each GradeID will be stored in a table within the database. The User will see a checkboxlist of the gradeIDs, and they will then be able to select as many gradeIDs from this list as they wish. Once they click 'submit', the gradeIDs they have selected will be passed to my stored procedure to perform the search.