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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I don't wanna create a new table, plz help 1

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
I have two SQL queries in an asp script of mine, which looks like :

-----------------------------------

set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN

StrQuery = "SELECT f.CustId, max(fd.UploadDate)as LastDate into tempererer from FileDescription f, FileDescription fd, Customer where f.CustId = fd.CustId and f.FileID = fd.FileID Group by f.CustId Order By f.CustId"
srt = "Select tempererer.CustId,Customer.CustName,tempererer.LastDate from Customer, tempererer where Customer.CustID = Tempererer.CustId"

set allcust=conntemp.execute(StrQuery)
set allcust=conntemp.execute(srt)
allcust.movefirst

-----------------------------------

As you can see I have two queries executed on the recordeset, this creates a new table called tempererer and this creates problems when the query is run more then once, How would I write my SQL query to give me the same effect without creating a new table? I was also wondering that I could delete the table after I have created it? How would I do this? Would/Could this create problems?

I perform both queries (StrQuery and srt) on the same recordset (allcust). The first query (StrQuery) executed on the recordset creates a table arccording to the requirements stated in StrQuery string. I then run another query on the same recordset (allcust) to get the required details. My problem is that because I create a new table this causes problems, how would I be able to achieve the same results from the queries without creating a new db table. Hope that clears things up.

Grateful for any help thanks.
 
You can do this with a subquery in the field list

SELECT Customer.Custname,
(SELECT MAX(UploadDate)
FROM FileDescription GROUP BY CustID
HAVING FileDescription.CustID = Customer.CustID)
AS LastUpdloadDate
FROM Customer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top