473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to link 2 SQL statements..........

Hi,

Quick question: How can I link 2 SQL statements in my asp page.
Originally I had 1 statement, but because it was fairly complex, it
took too long to parse.

SQL statement 1

strQuery = "Select ..............

Set RS = adoDataConn.Execute(strQuery)

then

Create SQL statement 2

strQuery2 = "SELECT stockmovements.JobNumber,
stockmovements.InStockMarker, orderlines.JobNumber"
strQuery2 = strQuery2 & " FROM stockmovements INNER JOIN orderlines ON
stockmovements.JobNumber = orderlines.JobNumber"
strQuery2 = strQuery2 & " WHERE (((stockmovements.JobNumber)=" &
RS("JobNumber") & "));"

(''''' RS("JobNumber") is pulled from SQL statement 1)
Set RS_Marker = adoDataConn.Execute(strQuery2)

_______________________________

When running the asp page, I want to pull out the field
stockmovements.InStockMarker (SQL statement 2) for each record in the
loop provide by SQL statement 1. I have tried, but all I get is
stockmovements.InStockMarker for the first record of SQL statement 1
listed for all the records.

Do I need to place a Do Loop within a Do Loop ???

Appreciate your help

Thanks

David.

Sep 19 '05 #1
1 1610
CJM
Look up the FETCH instruction in Books Online. It will allow you to loop
through the first set of rows, and run a separate query on each. I imagine
you could collate the results in a temp table...

I would be careful though. This is not necessarily the most efficient
approach. If you published your data structure and what you are trying to
acheive, we might be able to think of a better all-in-one query...

Chris

<da*********@scene-double.co.uk> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi,

Quick question: How can I link 2 SQL statements in my asp page.
Originally I had 1 statement, but because it was fairly complex, it
took too long to parse.

SQL statement 1

strQuery = "Select ..............

Set RS = adoDataConn.Execute(strQuery)

then

Create SQL statement 2

strQuery2 = "SELECT stockmovements.JobNumber,
stockmovements.InStockMarker, orderlines.JobNumber"
strQuery2 = strQuery2 & " FROM stockmovements INNER JOIN orderlines ON
stockmovements.JobNumber = orderlines.JobNumber"
strQuery2 = strQuery2 & " WHERE (((stockmovements.JobNumber)=" &
RS("JobNumber") & "));"

(''''' RS("JobNumber") is pulled from SQL statement 1)
Set RS_Marker = adoDataConn.Execute(strQuery2)

_______________________________

When running the asp page, I want to pull out the field
stockmovements.InStockMarker (SQL statement 2) for each record in the
loop provide by SQL statement 1. I have tried, but all I get is
stockmovements.InStockMarker for the first record of SQL statement 1
listed for all the records.

Do I need to place a Do Loop within a Do Loop ???

Appreciate your help

Thanks

David.

Sep 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff | last post by:
Please don't look down on me for this, but it is something I have never thought learning before. Lets say you have protected pages.. and youhave script at the top that directs the user to the...
33
by: Thomas Mlynarczyk | last post by:
Hi, I'm looking for a way to put a 1px solid border around the image in this link: <a href="some.html"><img src="some.gif"></a> Well, that, by itself, is simple. However, I would like to have a...
2
by: Ben | last post by:
Right now I have 1 table. The first part is the first and last name along with address etc. There is about 10-15 fields here. The second part consists of times, penalties and if they enter this...
10
by: Gary Hughes | last post by:
I'm getting the following error when attempting to link a managed C++ dll. I can't find any reference to these errors with google. Can anyone help? I've included the class definition causing the...
31
by: TC | last post by:
I'm looking for opinions on ways to show visitors, your links will send them off-site (to another website). The following was suggested: Look at the three links under the third paragraph:...
6
by: jeet_sen | last post by:
Hi, I have generated a table and have attached a pop up to display at onmouseover event of each cell. For each cell the pop up will display cell specific detailed data. I have generated the pop...
6
by: ntdude4 | last post by:
I am trying to make a variable link on a page. The page has a text box for a stock symbol. The code is: <input type=TEXTBOX Name="symtb" value="" size="10> The value of the text box {the stock...
28
by: RAB | last post by:
When my user closes the browser, I want the visited link to change to a "fresh" never been visited link once the user (on the same machine) reopens their browser. Here is the code I am using: ...
2
by: ahogan | last post by:
Previously posted on comp.databases.oracle.misc. Apologies to those who read both groups. I have created a link using generic connectivity from an Oracle 10.2.0.1 instance running on windows...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.