CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Delete oldest record

Print topic Send  topic

Author Message
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.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.