Today, We Will learn How to Use Joins in SQL Server in Urdu/Hindi Language. Basically, Joins are used to view record multiple tables. There are four types of Join, they are working different, but mostly use Inner Joins to view multiple table record. You have made many different tables, and you have included relationship one to many or many to many. So, you will run a query like “select * from table name”, you doesn’t display readable record. So, Users doesn’t understand it.
If you want to display readable record, you can use Joins in SQL Server to display record as well. Joins are used two or more tables are joined than you can display record as well. However, I have used mostly Inner joins, but sometimes use another join such as Left Join, Right Join or Full Join.
- How to Use Stored Procedure.
- How to Install SQL Server 2014.
- How to Use Trigger in SQL Server
- How to Use Sub-Query.
Furthermore, more than beginners facing problems how to use joins. And they are don’t understand it, basically, Joins are added multiple table’s column Names, and you can Match different tables IDs than you will get results as well.
Inner Join Example:
First of All, We will require tables to use Inner Joins. I have made three tables namely “Category”, “Product” and “JoinTable”.
12 CREATE TABLE CATEGORY (CT_ID INT PRIMARY KEY IDENTITY(1,1),CATEGORY_NAME VARCHAR(50))
12 CREATE TABLE PRODUCTS(PR_ID INT PRIMARY KEY IDENTITY (1,1),PRODUCTNAME VARCHAR(50))
I have inserted record in two tables:
1 INSERT INTO CATEOGRY VALUES('NOKIA'),('SAMSUNG')
12 INSERT INTO PRODUCTS VALUES ('LUMIA'),('GALAXY'),(' NOKIA LUMIA 801'), ('SAMASUNG GALAXY 7')
I have made “Category” and “ Product” Table relationship with another Table namely “JoiTable”.
123456 CREATE TABLE JOINTABLE(J_ID INT PRIMARY KEY IDENTITY(1,1),C_ID INT FOREIGN KEY REFERENCES CATEOGRY(CT_ID),PR_ID INT FOREIGN KEY REFERENCES PRODUCTS(PR_ID))
After that, I have inserted record on Join Table:
1 INSERT INTO JOINTABLE VALUES (1,1),(1,3),(2,2),(2,4)
That’s simple process to make tables, Insert Record and Use Relationship. Now come to point, If you want to search “joinTable”, then you can see below result:
But I want to display record readable, So, I want to use Joins. I have already told you, there are four Joins, and below used to Inner Join Tables and display record as well.
123456 SELECT CATEOGRY.CATEGORY_NAME,PRODUCTS.PRODUCTNAMEFROM JOINTABLE INNER JOINCATEOGRY ONJOINTABLE.C_ID=CATEOGRY.CT_IDINNER JOIN PRODUCTS ONJOINTABLE.PR_ID=PRODUCTS.PR_ID
After use, Inner join you can see the record on below as well.
Right Join Query and Result:
123456 SELECT CATEOGRY.CATEGORY_NAME,PRODUCTS.PRODUCTNAMEFROM JOINTABLE RIGHT JOINCATEOGRY ONJOINTABLE.C_ID=CATEOGRY.CT_IDRIGHT JOIN PRODUCTS ONJOINTABLE.PR_ID=PRODUCTS.PR_ID
Left Join Query and Result:
123456 SELECT CATEOGRY.CATEGORY_NAME,PRODUCTS.PRODUCTNAMEFROM JOINTABLE LEFT JOINCATEOGRY ONJOINTABLE.C_ID=CATEOGRY.CT_IDLEFT JOIN PRODUCTS ONJOINTABLE.PR_ID=PRODUCTS.PR_ID
Full Join Query and Result:
123456 SELECT CATEOGRY.CATEGORY_NAME,PRODUCTS.PRODUCTNAMEFROM JOINTABLE FULL JOINCATEOGRY ONJOINTABLE.C_ID=CATEOGRY.CT_IDFULL JOIN PRODUCTS ONJOINTABLE.PR_ID=PRODUCTS.PR_ID
However, that’s the simple process to use SQL Server Joins. I have made a video tutorial, I discussed How to Use SQL Server Joins and Display Record in Windows Form Application GridView. So, I recommended All of you watch below tutorial, you can more ideas about Joins in SQL Server and Display Record with GridView.
How to Use Joins in SQL Server Tutorial in Urdu
Thanks for Watch Complete video, after watch this video tutorial, I hope you have understood as well, and you will learn it something new. Kindly, share my content on social networks, and subscribe my website social networks pages like Facebook, Google+, Twitter, YouTube and Email for post updates.
If you have any question / suggestion about this topic, comment or email me after received your email or comment, I will reply with your answer maximum 24 hours. Thanks Again for a visit, Read my Complete Article and Watch my Videos. Keep touch my website, I will share very soon application like Android Application very soon.