Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         gja 
                                        Starting Member 
                                         
                                        
                                        2 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2011-03-23 : 19:36:59
                                            
  | 
                                             
                                            
                                            | I came across this small sql command to delete duplicated records in a table:delete from MyTable  where uniqueField not in  (select min(uniqueField)  from MyTable T2 where T2.dupField=MyTable.dupField)I have a very rudimentary knowledge of SQL, so can somone point me to the right direction to understand this construct ?MyTable T2: what is this, an alias, an object, what ?May be I need just a name to this expression, so I can search info about it.Thank you in advance. | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     SMerrill 
                                    Posting Yak  Master 
                                     
                                    
                                    206 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2011-04-29 : 19:36:53
                                          
  | 
                                         
                                        
                                          This portion identifies that "T2" is an ALIAS for "MyTable".FROM MyTable T2 This portion within parentheses makes a temporary copy of the original table, and it would be a query all by itself, except that the WHERE clause makes reference to the outer copy of the table.The WHERE clause is set up to match the duplicated fields.SELECT UniqueFieldName FROM InnerCopyOfTheSameTable T2  WHERE T2.dupField=MyTable.dupField   | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     gja 
                                    Starting Member 
                                     
                                    
                                    2 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2011-05-09 : 21:41:51
                                          
  | 
                                         
                                        
                                          | Thank you for your help. Despite the fact that the way the WHERE clause works is still a mistery for me, I think I have enough information to google about.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |