SQL Joins and Its Types || Steem Alliance Community.

in hive-150122 •  7 months ago 

Hello Everyone,


portfolio.jpg

In this post, we will discuss on SQL joins with a clear understanding of how it works and when to use joins. It does not meter how much experience you have in database field, it will help to get the data from different tables.

SQL joins are used to combine rows of more than one tables based on foreign and primary keys. It allows us to retrieve data from multiple tables in a single query from our databases.

Types of SQL Joins

  • Inner Join.
    It will return only those rows that have matching values in both tables.
  • Left Join.
    It will return all rows from the left table and matching rows from the right table.
  • Right Join.
    It will return all rows from the right table and matching rows from the left table.

These are the most important and common joins. there are more joins like self-join and cross join but mostly these three types of joins are used mostly. Joins play a crucial role in the report and data development. it is not meter which data base that you are using.

Nosectorcust_idname_1
110004270603SIKANDAR
210004270939ALI TARIQ
310005715170ALI HAMZA
410007796882IMRAN
51000953045UMAR
Nosectorcust_idTown
110004270603PESHAWAR
210004270939ALI PUR
310005715170GALA YOUSAF
410007796882KHANEWAL
51000953045YAZMAN

there are two tables, in one table name_1 exist and in second table town exist. i want to get the both name_1 and town. then join will use. the below is the syntax of joins.


SELECT 
u1.No , u1.sector ,  u1.cust_id , u1.name_1 , u2.Town,
FROM user1 as u1
INNER JOIN user2 as u2 
ON u1.cust_id= u2.cust_id;

Nosectorcust_idname_1Town
110004270603SIKANDARPESHAWAR
210004270939ALI TARIQALI PUR
310005715170ALI HAMZAGALA YOUSAF
410007796882IMRANKHANEWAL
51000953045UMARYAZMAN

image.png
Img Src

I hope, things will clear with above picture. you can see that in inner join only matching data will retrieve. we can use more than one join in a query to get the result of data. It would be my pleasure if you will share your opinion and reviews on this topic.

20230310_190323_0000.png

Please cast witness vote to @bangla.Witness or set proxy to @rme.

_
Vote @bangla.witness as witness
Set Proxy @rme as proxy

Special Thanks.

Cc: @rme
Cc: @hungry-griffin
Cc: @steemcurator02

Thanks for giving your precious time to my post.
Follow | Upvote | Share | Comments
Follow me on Instagram.
Instagram

🆃🅷🅰️🅽🅺 🆈🅾️🆄

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!