Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Multiple Queries

Author  Topic 

magyartoth
Starting Member

1 Post

Posted - 2005-06-15 : 14:12:11
I'm writing an ASP page for a project and it requires multiple queries. However, I'm trying to combine multiple SELECT statements, but can't figure out a way that actually works.

Basically, here are the SELECT statements I want to combine:

SELECT * FROM schoolrequest WHERE SLid=10

SELECT SLlastName FROM academicoffice
WHERE schoolrequest.SLsendToId=academicoffice.AOid
SELECT SLlastName FROM academicoffice
WHERE schoolrequest.SLbillToId=academicoffice.AOid
SELECT SLlastName FROM academicoffice
WHERE schoolrequest.SLrequestorId=academicoffice.AOid

SELECT * FROM diaryentry WHERE diaryentry.DEkeyValue=10
AND diaryentry.DEdeletedDate IS NULL

The academicoffice table just contains basic contact info, but needs to be used 3 times in the query to get specific contact info for 3 different contacts(SLsendToId, SLbillToId, SLrequestorId)

The diaryentry table contains info entered in by students. The DEkeyValue is actually the primary id of the schoolrequest table(SLid).

Any ideas?

Thanks,
M

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-06-15 : 21:59:46
Have you looked at UNION and JOIN in Books Online yet?

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -