SQL SERVER – Challenge – Puzzle – Why does RIGHT JOIN Exists
- by pinaldave
I had interesting conversation with the attendees of the my SQL Server Performance Tuning course.
I was asked if LEFT JOIN can do the same task as RIGHT JOIN by reserving the order of the tables in join, why does RIGHT JOIN exists?
The definitions are as following:
Left Join – select all the records from the LEFT table and then pick up any matching records from the RIGHT table
Right Join – select all the records from the RIGHT table and then pick up any matching records from the LEFT table
Most of us read from LEFT to RIGHT so we are using LEFT join. Do you have any explaination why RIGHT JOIN exists or can you come up with example, where RIGHT JOIN is absolutely required and the task can not be achieved with LEFT JOIN.
Other Puzzles:
SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal
SQL SERVER – Challenge – Puzzle – Usage of FAST Hint
Reference: Pinal Dave (http://blog.sqlauthority.com)
Filed under: Pinal Dave, SQL, SQL Authority, SQL Puzzle, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology