Is there some way to pass in multiple Values to a SQL search?
So for example I have a list of credits students earned and I want to find all credits earned between a date range, but only for select students.
I made a loop which cycles through every student and checks individually but it I wonder if there's a cleaner way.
You might take a look at how clauses which use the IN operator work. If you are just limiting the SELECT to a small number of students, then having something like the following could work for you:
SELECT ... FROM ... WHERE MY_DATE_FIELD > ? and ID_STUDENT IN ( 'ID1', 'ID2', ID3' )
But, I've never been clear about how well using an IN constraint scales in scenarios where:
- There are lots of possible values for the IN
- There is a lot of network latency
And so, I'm not going to guarantee you a win, but rather just encourage you to experiment with it.
Thank you. I tried it briefly and couldn’t get it to work. I’m traveling for the next few days but will try again next week. Thanks.