Hello Experts,
I have a table student.
select * from Table1
ID Name Course GPA
1 John Maths 3
1 John Science 3
1 John French 3
2 bob French 2
2 bob Maths 3
3 Mike Science 3
3 Mike Law 4
4 Chelsa Law 3
4 Chelsa Maths 2
4 Chelsa Science 1
5 Cloe English 2
5 Cloe French 3
5 Cloe Chineese 3
Now I want to write a query that get all the student info based on course they took.
For example
select * from Table1 where Course in ('Science','Maths')
That is an inline query ... Now I want to use parameterized query for the same.
I only took two courses as example. But what if I have multiple?
What I have tried:
Here is what I have tried...
I have got all the checked subjects into a string in vb.net
Dim strCoursecode As New List(Of String)
For Each dr As DataRow In dtCoursecodes.Rows
strCoursecode.Add(dr("Course"))
If strCoursecode.Count > 0 Then strCoursecode.Add(String.Empty)
String.Join(vbTab, strCoursecode.ToArray)
My Stored procedure will pass parameters like 'Maths Science'
@TEST is my parameter
SELECT * FROM TABLE1 WHERE COURSE IN ( @TEST )
Now can anyone help me with the query on how to pass parameterized query for IN clause