Using Constants for queries... (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


AllenD -> Using Constants for queries... (4/9/2002 14:17:05)

Hello All, ok here we go...

I need to queries on the same database, but on many different items, many different times...example:

I need a query that will tell me the last time a database entry was made for Apples...then for Oranges...then for Grapes...etc, etc...this goes on for 30 or more times...

I already have the database built and working with the date/time being captured. I do not want to write 30 different select statements that contain SELECT grapes from .... etc...

So, can I write some kind of variable or constant that contains all the fruits then using a loop that will query the database based on my variable? If anyone has an example or good website with examples it would be much appreciated! Thanks...





alveyuk -> RE: Using Constants for queries... (4/9/2002 18:56:43)

You did not supply column names so I'll make them up as I go along:-

select FruitName, max(ChangeDate) as LastChanged
from Fruit_Posting
group by FruitName
order by FruitName

This will provide a list of all the Fruits together with the date of their last database entry. This list can be used to drive a DRW which will allow you display the results in the usual table format.

Ken Alvey




AllenD -> RE: Using Constants for queries... (4/10/2002 10:55:10)

Sorry, I should have been more specific, I have a hard time putting this stuff into words. Each fruit is a column, and the fruits are yes/no check off boxes. So thats why I need to loop through the database every time with a different set of fruits every time...Is there a way to do this?





AllenD -> RE: Using Constants for queries... (4/10/2002 12:28:22)

Here is an example of the select statement that I have that I need to change with a loop using a different variable every time where you see MYVARIABLE.

<%
dim ORSp
Set oRSp=server.createobject("ADODB.recordset")
sqltext="Select "
sqltext = sqltext & MYVARIABLE & "datestamp, empid from Everyone "
sqltext = sqltext & "WHERE (datestamp LIKE "
sqltext = sqltext & "'%" & mydatetoday & "%'"
sqltext = sqltext & " AND MYVARIABLE = True)"
sqltext = sqltext & "ORDER BY ID DESC"
oRSp.open sqltext, "dsn=conndata2"%>





AllenD -> RE: Using Constants for queries... (4/10/2002 17:22:24)

I figured it out...Thanks guys.





rdouglass -> RE: Using Constants for queries... (4/11/2002 8:06:41)

So what was the solution???

 




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875