0

I am trying to make a query which will search for the ID's 5, 6 and 23(Those are just random numbers and could potentially be more). Rather than making a loop in my code to query each separate ID I was wondering if it was possible to query them all at once and return each row for the individual IDs.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by sourceskill
0

Hello,

All you have to do is select from a list like this:

Select * from table1
where ID in (5, 6, 23)
0

I have the same question somewhat... except I need the query string to populate the values for the IN statement this is the code I have but it's not working and I'm stuck and am in DIRE need of an answer:
<%
Dim rsAuto__print
For i=1 to (Trim(UCase(Request.QueryString("print"))).Count
If (Trim(UCase(Request.QueryString("print"))) (i) = Trim(UCase(rsAuto.Fields.Item("vin").Value)) Then
rsAuto__print = Trim(UCase(Request.QueryString("print"))
End If
Next
%>
<%
Dim rsAuto
Dim rsAuto_cmd
Dim rsAuto_numRows

Set rsAuto_cmd = Server.CreateObject ("ADODB.Command")
rsAuto_cmd.ActiveConnection = MM_Regal_STRING
rsAuto_cmd.CommandText = "SELECT * FROM AUTODETA as t1 LEFT JOIN MAKES AS t2 ON t1.makesx = t2.makesx WHERE vin IN ("& rsAuto__print &")"
rsAuto_cmd.Prepared = true
rsAuto_cmd.Parameters.Append rsAuto_cmd.CreateParameter("param1", 200, 1, 255, rsAuto__print) ' adVarChar

Set rsAuto = rsAuto_cmd.Execute
rsAuto_numRows = 0
%>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.