Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 26th, 2015, 03:12 PM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pulling in results from first query into second

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling out data -- very surprising results to a newbie... wsprague XSLT 4 May 7th, 2009 12:19 PM
query pulling null records jcarswelljr SQL Server 2005 2 March 20th, 2009 09:10 AM
Edit Query Results in Results Grid druid2112 SQL Server 2005 1 June 28th, 2007 08:49 AM
different results were given for the same query madhusrp SQL Server 2000 2 May 9th, 2006 01:54 AM
Date query pulling records from yesterday Justine Access 5 June 27th, 2004 03:45 PM



All times are GMT -4. The time now is 05:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.