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  | 
                             
                            
                                    | 
                                         svibuk 
                                        Yak Posting Veteran 
                                         
                                        
                                        62 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2014-02-19 : 07:38:22
                                            
  | 
                                             
                                            
                                            | SELECT t1.id,name, from table1 t1 INNER join table t2 on t1.id=t2.pidcase when type='A' thenInner join table3 t3 on t1.id=t3.idelseInner join table4 t4 on t1.id=t4.idEND | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     stepson 
                                    Aged Yak Warrior 
                                     
                                    
                                    545 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-02-19 : 07:59:18
                                          
  | 
                                         
                                        
                                          | [code]SELECT t1.id,name, from table1 t1 	INNER join table t2 on t1.id=t2.pid		LEFT JOIN table3 t3 on t1.id=t3.id AND TYPE='A'	LEFT JOIN table4 t4 on t1.id=t4.id AND TYPE<>'A'[/code]sabinWeb MCP  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     svibuk 
                                    Yak Posting Veteran 
                                     
                                    
                                    62 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-02-19 : 23:51:59
                                          
  | 
                                         
                                        
                                          quote: Originally posted by stepson
 SELECT t1.id,name, from table1 t1 	INNER join table t2 on t1.id=t2.pid		LEFT JOIN table3 t3 on t1.id=t3.id AND TYPE='A'	LEFT JOIN table4 t4 on t1.id=t4.id AND TYPE<>'A' cant use it in this way table3 t3table4 t4both this tables can have same id but the type will be differenteg :id      Name     Type1        abc       A2        xyz       A1        mno       D3        bbb       Athe data can be in this waysabinWeb MCP
    | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     marcusn25 
                                    Yak Posting Veteran 
                                     
                                    
                                    56 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-03-04 : 18:37:19
                                          
  | 
                                         
                                        
                                          | Would this not solve it for you?SELECT t1.id,name, from table1 t1 	INNER join table t2 on t1.id=t2.pid		LEFT JOIN table3 t3 on t1.id=t3.id AND t1.TYPE='A' AND t3.TYPE='A'	LEFT JOIN table4 t4 on t1.id=t4.id AND t1.TYPE<>'A' AND t4.TYPE<>'A'Marcus I learn something new everyday.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |