How to Join two or more than two Tables using multiple columns | How to Join Multiple Tables

SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
Different Types of SQL JOINs
(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Returns all records from the left table,
and the matched records from the right table,
The LEFT JOIN keyword returns all records from the left table (table1),
and the matched records from the right table (table2).
The result is NULL from the right side, if there is no match.
RIGHT (OUTER) JOIN: Returns all records from the right table,
and the matched records from the left table
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table,
The FULL OUTER JOIN keyword returns all records when there is a match in left (table1)
or right (table2) table records.
Note: FULL OUTER JOIN can potentially return very large result-sets!
Tip: FULL OUTER JOIN and FULL JOIN are the same.
You can follow us on the below social media handles:-
Blog: - thedatamillennials.blogspot.com/
Facebook:- / the-data-millennials-5...
Instagram: - / the_data_millennials
LinkedIn: - / data-millennials-6b5a0...
Twitter: - / datamillennials

Пікірлер: 63

  • @nsangchat3529
    @nsangchat35292 жыл бұрын

    OMG you are a god !!! I have been looking at minimum 10 videos and yours are the most CLEARLY illustrated ONE !! Thanks a lot

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    @N Sangchat, Hope you are well and I am Glad that our video was helpful . Request you to please help us to reach out to all of those people who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com

  • @Tabla_Tejas67
    @Tabla_Tejas67 Жыл бұрын

    OMG you are a god !!! I have been looking at minimum 10 videos and yours are the most CLEARLY illustrated ONE !! Thanks a lot

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    Hi @Tejas Kumar. I am Glad that our video was useful and helpful for you . Request you to please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics. And happy new year in Advance.

  • @glorygabriel2862
    @glorygabriel28622 жыл бұрын

    Explanations are so clear. Thanks a bunch, I understand it clearly now. Please make a video for full outer join

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    Hi Glory, I am Glad that our video is helpful . and i believe outer join explanation is uploaded in the sql playlist Request you to please help us to reach out to all of those people who might want to learn something by sharing our content. And Request you to please subscribe our channel to learn more about such topics *In case if you are struggling with any topic, Please connect with us on the given email id and we can connect over a quick google meet call and help you to resolve it.

  • @roi_4_dayz
    @roi_4_dayz Жыл бұрын

    Great tutorial. Thank you for your help!

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    HI @roi_4_dayz I am Glad that our video was useful and helpful . Request you to please check out our other videos of Excel, SQL and Google data studio ( Looker) and also please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @justintunley8347
    @justintunley834711 ай бұрын

    Extremely helpful

  • @thedatamillennials

    @thedatamillennials

    9 ай бұрын

    apologies for the delayed response. I am Glad that our video was useful and helpful . Request you to please check out our other videos of Excel, SQL and Google data studio ( Looker) and also please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @alexg97343
    @alexg97343 Жыл бұрын

    Fantastic fantastic you explained this so clearly please continue dropping videos. I am subscribing

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    Hi Alex, I am Glad that our video was helpful and you have subscribed our channel. *Request you to please help us to reach out to all of those people who might want to learn something new by sharing our content.* In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com

  • @DilipKumar-ch5uu
    @DilipKumar-ch5uu Жыл бұрын

    This is perfect ❣️

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    Hi Dilip, I am Glad that our video was helpful . Request you to please help us to reach out to all of those people who might want to learn something new by sharing our content. *And Request you to please subscribe our channel to learn more about such topics*

  • @Radhe_kanha0
    @Radhe_kanha0 Жыл бұрын

    Well explained.

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    HI @Neha Jha, I am Glad that our video was useful and helpful . Request you to please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @abhishekmahapatra4270
    @abhishekmahapatra4270 Жыл бұрын

    Thank You Sir. Concept is very well explained.

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    HI @Abhishek Mahapatra, I am really Glad that our video was useful and helpful for you. Request you to please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @sharoonhoney1054
    @sharoonhoney1054 Жыл бұрын

    Outstanding explanation 😃

  • @thedatamillennials

    @thedatamillennials

    9 ай бұрын

    apologies for the delayed response. I am Glad that our video was useful and helpful . Request you to please check out our other videos of Excel, SQL and Google data studio ( Looker) and also please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @sharoonhoney1054

    @sharoonhoney1054

    9 ай бұрын

    @@thedatamillennials acknowledged 🥰

  • @thedatamillennials

    @thedatamillennials

    6 ай бұрын

    thanks

  • @danielalejandrorobayo4630
    @danielalejandrorobayo4630 Жыл бұрын

    I noticed that all the 3 tables had the same key "roll_no", so it's somehow easy. However, what happens for example when table 1 and 2 has a common key, and table 2 and 3 have a different key, how to relate table 1 and 3 in this case?

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    In that case you have to get the output by joining table 1 and table 2( lets say output 1 ) and then you have to get output by joining table 2 and table 3 ( lets say output 2) and then you can relate output 1 and output 2 using the common key . you question is quite good and i think i should create a video on this question. i will upload a video on your question and share the link here in the comment.

  • @adarshverma3372
    @adarshverma337210 ай бұрын

    Great

  • @thedatamillennials

    @thedatamillennials

    9 ай бұрын

    apologies for the delayed response. I am Glad that our video was useful and helpful . Request you to please check out our other videos of Excel, SQL and Google data studio ( Looker) and also please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @subhadipmodak1321
    @subhadipmodak13212 жыл бұрын

    great video sir😍😍😍

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    Hi @subhadip modak, I am Glad that our video was helpful . Request you to please help us to reach out to all of those people who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com

  • @subhadipmodak1321

    @subhadipmodak1321

    2 жыл бұрын

    @@thedatamillennials obviously sir, i suggest this channel who are wants to something new & advance topic.

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    @@subhadipmodak1321 thank you , we would really appreciate your help.🙏

  • @ToLoHasso
    @ToLoHasso Жыл бұрын

    One Question If i need to print the name and percentage that they got from the same data how we can write the query for the same??? Please reply fast i am very curious

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    HI @To Lo Hasso, Apologies for delayed response. Below is the query which you have asked. #use youtube_example; select final.name, final.class, sum(final.Marks) as total_marks, concat(round(((sum(final.Marks)/500)*100),0),"%") as student_percentage from ( select sd.Roll_No, sd.class, sd.name, scd.Course_name, smd.Marks from student_data as sd left join Student_Course_Data as scd on sd.Roll_No=scd.Roll_No left join student_marks_data as smd on(sd.roll_no=smd.Roll_No and scd.Course_name=smd.Course_name) ) as final group by 1,2 ;

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    @To Lo hasso, Request you to please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com

  • @leecallaghan4625
    @leecallaghan46258 ай бұрын

    good day . i have an issue with my leads platform . when i enter a lead it says it already exists . i wa looking into this issue and found that it maybe an issue with a DUPLICATE KEY . does anyone have any idea .

  • @thedatamillennials

    @thedatamillennials

    6 ай бұрын

    you have the issue with primary key, let me know if you are still facing the issue

  • @m.a.s3072
    @m.a.s30724 ай бұрын

    If you change a record or some data in one table does it change in all the tables that reference it?

  • @thedatamillennials

    @thedatamillennials

    Ай бұрын

    no , it only changes the specific data that you have change.In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com

  • @gayatrichaudhari4306
    @gayatrichaudhari430611 ай бұрын

    We can use distinct keywords for marks

  • @thedatamillennials

    @thedatamillennials

    9 ай бұрын

    yes you can use

  • @farahamirah2091
    @farahamirah20912 жыл бұрын

    hi, i have question, if we are using left join from student_data as sd left join Student_Course_Data as scd so the table on the left is sd , let say we add left join student_marks_data as smd on scd.Roll_No=smd.Roll_No are we consider table scd as left table for joining or still sd?

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    HI Farah, The first table which you have used in From clause (in this case student data as sd ) will always be the let table.. Hope the above explanation clears your confusion. In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com Request you to please help us to reach out to all of those people who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @farahamirah2091

    @farahamirah2091

    2 жыл бұрын

    Understood that,sure i will spread your video with my colleague

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    @@farahamirah2091 Thanks. We would really appreciate your help.

  • @arunajain9515
    @arunajain95155 ай бұрын

    why to use left join twice cannot we get the answer only with second left join

  • @thedatamillennials

    @thedatamillennials

    5 ай бұрын

    i have used two joins to give a taste that how you can join two or more than two table at once

  • @deepthimurali962
    @deepthimurali9622 жыл бұрын

    Hi, can you tell why we went for left join for both joins?

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    Hi @Deepthi, We went for left join for both the table , because as per our requirement we required all the rows from both of the tables

  • @pradeepravi9608
    @pradeepravi96082 жыл бұрын

    Sir can we use where condition in left join

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    HI Pradeep, Yes you can use where condition in Left join. after joining the table you can use the where clause on left table's Column. For example suppose you have 2 table -- table 1 and table 2 and your table table1 is your left table then you can use the where condition like this Select t1.col1,t1.col2,t2.col3 from table 1 as t1 left join table2 as t2 where t1.col1="condition". In case if you are struggling with any topic, Please connect with us on the below given email id and we can connect over a quick google meet call and help you to resolve it. Email Id:- master.datamillennials@gmail.com Request you to please help us to reach out to all of those people who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics

  • @pradeepravi9608

    @pradeepravi9608

    2 жыл бұрын

    @@thedatamillennials i can't understand sir

  • @thedatamillennials

    @thedatamillennials

    2 жыл бұрын

    @@pradeepravi9608 Lets connect over google meet and will clear your confusion . You can send google meet link or invite on the below email master.datamillennials@gmail.com

  • @nsnreddy4147
    @nsnreddy41475 ай бұрын

    Could you please share with us excel sheet for practicing?

  • @thedatamillennials

    @thedatamillennials

    5 ай бұрын

    Please drop me a note on below email id and I will share the data with over the email master.datamillennials@gmail.com

  • @nexsitymusichub1811
    @nexsitymusichub1811 Жыл бұрын

    hello please what is 'sd ' and ' 'scd'

  • @thedatamillennials

    @thedatamillennials

    9 ай бұрын

    hi sd and scd is the alias name of the table that i had given while joining the tables.

  • @sahilrohilla8796
    @sahilrohilla8796 Жыл бұрын

    can you share this video insert query?

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    Hi @Sahil Rohilla, Apologies for delayed response. As requested in the comment, please find the below query used in this video. select sd.Roll_No, sd.class, scd.Course_name, smd.Marks from student_data as sd left join student_Course_Data as scd on sd.Roll_No=scd.Roll_No left join student_marks_data as smd on (sd.Roll_No=smd.Roll_No and scd.Course_name=smd.course_name) And Request you to please subscribe our channel to learn more about such topics

  • @neharoy6859
    @neharoy6859 Жыл бұрын

    Can someone pls explain what query we can use in this to get the final o/p Source A ID Name State 1 A Delhi 2 B Delhi 3 C Source B ID Name State 1 A Delhi 3 C Haryana 4 D Mumbai 5 E Final Output: ID Name State 1 A Delhi 2 B Delhi 3 C Haryana 4 D Mumbai 5 E Null

  • @thedatamillennials

    @thedatamillennials

    Жыл бұрын

    Hi @Neha Roy There are multiple ways to solve this kind of problem statement. But one of the easiest way is to use full join. The Full Join basically returns all records from the left table and also from the right table. For example, let’s say, we have two tables, Table A and Table B. When Full Join is applied on these two tables, it returns us all records from both Table A and Table B. If the condition is not met, then the null value is displayed instead Please let me know, if you want me to create a video on your problem statement

  • @SeniorTravels
    @SeniorTravels Жыл бұрын

    content is blurred

  • @thedatamillennials

    @thedatamillennials

    9 ай бұрын

    ok , will try to make videos in high definition

  • @tejindersingh4580
    @tejindersingh45805 ай бұрын

    Aise to koi paise le k bhi ni samjhata !! 🫀

  • @thedatamillennials

    @thedatamillennials

    5 ай бұрын

    I am Glad that our video was useful and helpful . Request you to please check out our other videos of Excel, SQL and Google data studio ( Looker) and also please help us to reach out to all your friends and family members who might want to learn something new by sharing our content. And Request you to please subscribe our channel to learn more about such topics