| Combine Duplicates [message #37390] | 
			Tue, 05 February 2002 04:52   | 
		 
		
			
				
				
				
					
						
						Rich Petersen
						 Messages: 22 Registered: February 2002 
						
					 | 
					Junior Member  | 
					 | 
		 
		 
	 | 
 
	
		Hello all, 
 
I have just started my PL/SQL studies, but this is well above my current experience. 
 
I have a table called MAINFOLDER, with, among other things, has a NAME and a FOLDER_ID table. This FOLDER_ID is a foreign key in the BINDER table. 
 
The customer has run a load multiple times, and now they have duplicates within the MAINFOLDER table. SO lets say we have a NAME/FOLDER_ID as follows: 
 
NAME1    5 
NAME1    6 
 
And in the BINDER table, we have the same column, FOLDER_ID. 
 
I have to delete one of the folders: 
 
Delete from MAINFOLDER where FOLDER_ID=6 
 
then I have to go to the BINDER table and update it, and set the deleted FOLDER_ID to the one that still exists: 
 
UPDATE BINDER SET FOLDER_ID=5 where FOLDER_ID=6. 
 
However, I have to do this numerous times, since they have many duplicate folders. Also, some folders have more than one duplicate. 
 
Anyway to do this with a script?
		
		
		
 |  
	| 
		
	 | 
 
 
 | 
	| 
		
 |