0

Hi!

i have a table with 3 fields: ParentFolder,DocumentNo and VersionNo
the DocumentNo give each document a unique number. ParentFolder is a number specifying which folder a document is in. and each document(with same name) can have many VersionNo(1,2,3 etc).

i am creating a house keeping function for user. this function accepts a number from user specifying how many version he would like to keep.

i have created a page that list out all folder in the db with a checkbox. user is able to checked the folder they want to housekeep.

the problem is how do i write a sql that will 'group' documents with same name, delete the document base on the input.

since the system only get the folder id and not each document id individually the system won't be able to pinpoint each document.

in dire need of help
Thanks in advance

3
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by pclfw
0

you will either need to add a second table to keep track of document names and Document numbers relations or add a DocumentName Column to your table.

0

Sounds like work for a stored procedure.
The problem being that the easiest way to do this is to have a sub-query select the documents grouped on the parentfolder and documentnumber, and use a 'TOP X' qualifier. Then have the main select query use the output of the subquery with the NOT IN comparison.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.