Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write complicated query in ASP?

Status
Not open for further replies.

zhongwei

Programmer
Jan 25, 2002
30
0
0
CA
Hi,everyone,I have some problem in ASP,I need help.
Our database is Access2000, we have Query1,Query2,base on them we made Query3.
Query3:
SELECT Query1.JobNum, Query1.launchDate, Query2.Company, Query2.MaxOfIssueDate
FROM Query2 INNER JOIN Query1 ON Query2.Jobnum = Query1.JobNum;

If I want to get same result through ASP,How can I put three Query together,and write SQL for it?
thanks for any suggestion,your help will be greatly appreciated.
 
Cant you build all this into one or is that not your problem?

gsc1ugs gsc1ugs
"Cant see wood for tree's...!"
 
Hi,gsc1ugs

Actually I'm new in ASP,i can't follow your idea,could you write some detail about it?Thanks.
 
zhongwei:

I'm not an expert on joining tables, but perhaps checking out the tutorial "SQL Join" at could give you some idea on how to proceed - they give what seems to be an illustrative example!

DrMaggie ---------
"Those who don't know the mistakes of the past won't be able to enjoy it when they make them again in the future."
— Leonard McCoy, MD (in Diane Duane's Doctor's Orders)
 
You're Query builder in Access should perform nicely in building the apropriate sql statement for you using all fields from all tables that you need. Try building all into one statement as it will run a little faster. -Ovatvvon :-Q
 
Give me your three queries and i'll build you one.. gsc1ugs
"Cant see wood for tree's...!"
 
Write those queries in Access and why don;t u execute the 3rd query from ASP. There is no need to write the query in ASP .. U can just execute them from ASP and get the recordset.

Srinu...
 
Hi,everyone ,thank you for your suggestion,I think I didn't make myself clear,so I put further detail here:
the Query3 based on Q1 & Q2. if Q1 & Q2 whitout any condition,just execute Q3 in ASP is ok.but Q2 has "having" clause,While execute Q3 we need to pass parameter to Q2 in ASP,This is my problem.
Q1:
SELECT Inquery.JobNum, Last(Inquery.date) AS Launchdate
FROM Inquery
GROUP BY Inquery.JobNum;
Q2:
SELECT FeedBack.Jobnum, FeedBack.Company, Max(FeedBack.SendDate) AS MaxofsendDate
FROM FeedBack
GROUP BY FeedBack.Jobnum, FeedBack.Company
HAVING (((FeedBack.Company)=@parameter));
Q3:
SELECT Query1.JobNum, Query1.launchDate, Query2.Company, Query2.MaxOfsendDate
FROM Query2 Right join Query1 ON Query2.Jobnum = Query1.JobNum;

Thanks for everyone's help



 
I agree... get the recordsets and do condition on 1 and 2 with 3

gsc1ugs gsc1ugs
"Cant see wood for tree's...!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top