 
- Forum
- Databases
- SQL difference between self join and correlated queries
 
 
 
	
		
		
	
	
	
	
	
		
			
- 
	
	
		
			
			
				Junior Member
			
			
			
			
				
					
						  
 
					    
				 
 
			
				
				
				
					difference between self join and correlated queries
				
					
						
							difference between self join and correlated queries
 
 
 
 
 
 
 
 
 
- 
	
	
		
			
			
				Expert Member
			
			
			
			
				
					
						  
 
					    
				 
 
			
				
				
				
					Re: difference between self join and correlated queries
				
					
						
							Joining a table to itself is known as selft join. The self join can be viewed as a join of two copies of the same table.
 
 SELECT e1.last_name||' works for '||e2.last_name
 "Employees and Their Managers"
 FROM employees e1, employees e2
 WHERE e1.manager_id = e2.employee_id
 AND e1.last_name LIKE 'R%';
 
 
 Correlated queries are subqueries in which inner query is evaluated once per each row processed by the outer query. They take more processing time.
 
 
 A correlated subquery can return the same result as a self join, but can be used where a join cannot, such as in an UPDATE, INSERT and DELETE statement.
 
 
 
 
 
 
				
				
				
					
						Last edited by krishnaindia2007; 04-05-2008 at 12:05 AM.
					
					
				 
 
 
 
 
- 
	
	
		
			
			
				Contributing Member
			
			
			
			
				
					
						  
 
 
			
				
				
				
					Re: difference between self join and correlated queries
				
					
						
							Self join is joining the one table to itself, but when you come to the corealted queries we can use the different tables and in the corelated queries the inner query executes first, but it will dependa on the outer query. so they are interrelated to each other.
 
 
 
 
 
 
 
 
 
- 
	
	
		
			
			
				Junior Member
			
			
			
			
				
					
						  
 
					    
				 
 
 
 
 
	
	
	
	
	
	
	
	
	
	
	
	
		
		
			
				 Posting Permissions
				Posting Permissions
			
			
				
	
		- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-  
Forum Rules