Please I need help
I have a list of ClassID that is stored based on users multi select on a listview
For example ClassID might contain
301
302
303
304
Now I need to find InstructorID where classID matches all the value in the above list.
I am using this query
But the problem is the query is returning InstructorID where ClassID matches any of the ClassIDs. I want it to return Instructor ID where ClassID matches all of the ClassIDs in the string.
Can someone help with this?
I have a list of ClassID that is stored based on users multi select on a listview
For example ClassID might contain
301
302
303
304
Now I need to find InstructorID where classID matches all the value in the above list.
I am using this query
Code:
Dim assSQL = "Select InstructorID from ClassInstructors where ClassID = @P0"
For i = 1 To classIDs.Count - 1
assSQL &= " UNION Select InstructorID from ClassInstructors where ClassID = @P" & i.ToString
Next
Dim assCMD As New SqlCommand(assSQL)
For i = 0 To classIDs.Count - 1
assCMD.Parameters.Add(New SqlParameter With {.ParameterName = "@P" & i.ToString, .SqlDbType = SqlDbType.VarChar, .Size = 50, .Value = classIDs(i)})
Next
Can someone help with this?