Hi guys
I have two sql queries on my page which queries two separate car tables. As an example, the first query simply queries table1 and returns any car models that are manufactured by Aston Martin.
<%
sql = "Select model from table1 where manufacturer = 'aston martin'"
oRs.Open sql, oDBConn
If oRs.eof then
Else
Do while not oRs.eof
manufacturer = oRs("manufacturer")
oRs.MoveNext
loop
End If
%>
So, I would get results like:
DB9
DB7
Vantage
Vanquish
DB5
so far so good…
The second query searches table2 for any records which match a set of car models, it would then display the top speed for each of those models. So…
<%
sql = "Select model, topspeed from table2 WHERE model IN ('###', '###', '###')"
oRs.Open sql, oDBConn
If oRs.eof then
Else
Do while not oRs.eof
%>
<%=oRs("model")%> = <%=oRs("topspeed")%>
<%
oRs.MoveNext
loop
End If
%>
Here’s where I have my problem. I need to pull in the models from the first query into the “IN” statement in the second query. Thus it is executed as follows:
sql = "Select model, topspeed from table2 WHERE model IN ('DB9', 'DB7', 'Vantage', 'Vanquish', 'DB5')"
There is no set number of models. So, For a Porsche query, I may only have 3 models but for Audi I may have 13 models that need to be pulled into the second query.
I am an utter complete novice and have been looking at how I can do this for the past 3 days! The closest I have come is something called an array but this is way above my head. Is there an “easy” solution to this? Any help would be really appreciated.
I look forward to hearing from you
Best regards
Rod from the UK