|
| |
|
|
AllenD
Posts: 258 From: Dayton, OH, USA Status: offline
|
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
Posts: 80 Joined: 4/4/2002 From: Lincs United Kingdom Status: offline
|
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
Posts: 258 From: Dayton, OH, USA Status: offline
|
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
Posts: 258 From: Dayton, OH, USA Status: offline
|
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"%>
|
|
|
|
rdouglass
Posts: 9186 From: Biddeford, ME USA Status: offline
|
RE: Using Constants for queries... - 4/11/2002 8:06:41
So what was the solution???
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|