Mammer
|
| Posted: 05/13/2002, 7:23 AM |
|
I need help working out the vbscript (ASP w/templates and Access 2002) to delete the oldest record in a table that contains a list of the most recent records accessed by a user. This table holds the last 6 customer records viewed/edited by the user. When the user views or edits a customer record, I need to add it the table if it is not already in the table and then delete the oldest record to keep the table at a maximum of six records.
Thanks!
|
|
|
 |
Mehmet Ozdemir
|
| Posted: 05/13/2002, 4:28 PM |
|
Here you go champ:
Delete from YOURTABLE where YOURID not in (select top 6 YOURID from YOURTABLE order by YOURSORTFIELD)
Summary: select the top 6 records then exclued tem from the delete, you will need to add additional criteria to resctric this by user / application etc.
YOURTABLE: Your Table you want delete greater 6
YOURID: PK
YOURSORTFIELD: Perhaps a timestamp to sort newest and oldest records, can also a counter.
|
|
|
 |
|