Total Page Preview:   000000000337

What is left join in SQL in Engish and Hindi

 

Left Join in SQL in English

In SQL, a left join is used to combine the result sets of two tables based on the matching values of a specific column(s), where all the records from the left table are included and matching records from the right table are also included, but non-matching records from the right table are excluded.
Here is an example of a left join in SQL:
Suppose we have two tables, "employees" and "departments". The "employees" table contains information about the employees, including their ID, name, and department ID. The "departments" table contains information about the departments, including the department ID and department name.
Employees Table:
Departments Table:
To perform a left join on these tables based on the department ID, we would use the following SQL statement:
The result set of this SQL statement would be:
As you can see, all the records from the left table (employees) are included in the result set, even if there are no matching records in the right table (departments). For example, the department with ID 3 (Finance) has no matching employees in the "employees" table, so the corresponding fields in the result set (EmployeeID and EmployeeName) are NULL. On the other hand, matching records from the right table are included, such as the department names in this example.

 

 

Left Join in SQL in Hindi

"Left join" bhi ek SQL join operator hai, jo do ya zyada tables ko merge karta hai. Left join mai, left table ke saare rows show hote hai, saath hi right table ke matching rows bhi show hote hai. Agar right table mai koi matching row na ho, toh NULL value show hota hai.

Ek detailed example ke through samjhate hai. Consider kare ki humare paas do tables hai, "employees" aur "departments":
employees table:
departments table:
Ab hum left join ka use karke "employees" aur "departments" tables ko merge karenge. Hum left join tab use karte hai, jab hume left table ke saare rows show karne hai, chahe right table mai matching row hai ya nahi. SQL query is tarah ka hoga:
Is query ke output mai, "employees" table ke saare rows show honge, chahe unke corresponding "departments" table mai matching row hai ya nahi. Agar right table mai matching row nahi hai, toh NULL value show hoga. Niche diye gaye table mai query ka output hai:
Is output mai, first row mai "employees" table ke first row ke corresponding "departments" table mai matching row hai, isliye dono tables ki details show ho rahi hai. Lekin last row mai "employees" table ke fourth row ke corresponding "departments" table mai koi matching row nahi hai, isliye "departments" table ke columns mai NULL values show ho rahe hai. Is tarah se, left join ka use karke hum left table ke saare rows aur right table ke matching rows ko merge kar sakte hai.
 
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: