Which one is Better and why ? Use SQL subselects to consolidate queries on multiple tables into a single statement Or Use Left Outer Join Example: Table Employee(Employee_ID,Employee_Name,Department_ID) Table Department(Department_ID,Department_Name) · Table Employee has million records, table Department has Few Records · Some Of the employees does not have department Which Query is better for performance? SelectEmployee_ID,Employee_Name, (Select Department_Name From Department Where Department .Department_ID = Employee. Department_ID) as Department_NameFrom Employee OR Select Employee_ID,Employee_Name, Department_Name From EmployeeLeft Outer JoinDepartmentOn Department .Department_ID = Employee. Department_ID
Check the execution plans that SQL generates for the queries. If they are identical, it doesn't matter which of the two versions you use.
I prefer joins over subqueries. The SQL optimizer can sometimes transform a subquery into a join, but not always. Plus, I think the join more clearly communicates what you're trying to do.