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

Поделиться
HTML-код
  • Опубликовано: 30 янв 2022
  • 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
    @nsangchat3529 2 года назад +4

    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 года назад +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 Год назад +1

    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
    @glorygabriel2862 2 года назад

    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 Год назад +1

    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

  • @alexg97343
    @alexg97343 Год назад +1

    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

  • @justintunley8347
    @justintunley8347 Год назад +1

    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

  • @DilipKumar-ch5uu
    @DilipKumar-ch5uu Год назад +2

    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*

  • @abhishekmahapatra4270
    @abhishekmahapatra4270 Год назад +1

    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

  • @Radhe_kanha0
    @Radhe_kanha0 Год назад +1

    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

  • @sharoonhoney1054
    @sharoonhoney1054 Год назад +1

    Outstanding explanation 😃

    • @thedatamillennials
      @thedatamillennials  9 месяцев назад +1

      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 месяцев назад +1

      @@thedatamillennials acknowledged 🥰

    • @thedatamillennials
      @thedatamillennials  6 месяцев назад

      thanks

  • @danielalejandrorobayo4630
    @danielalejandrorobayo4630 Год назад +2

    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  Год назад +4

      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
    @adarshverma3372 10 месяцев назад +1

    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

  • @m.a.s3072
    @m.a.s3072 4 месяца назад

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

    • @thedatamillennials
      @thedatamillennials  2 месяца назад

      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

  • @subhadipmodak1321
    @subhadipmodak1321 2 года назад +1

    great video sir😍😍😍

    • @thedatamillennials
      @thedatamillennials  2 года назад +1

      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.🙏

  • @leecallaghan4625
    @leecallaghan4625 8 месяцев назад +1

    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  7 месяцев назад

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

  • @ToLoHasso
    @ToLoHasso Год назад +2

    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  Год назад +1

      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  Год назад +1

      @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

  • @farahamirah2091
    @farahamirah2091 2 года назад

    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 года назад +1

      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
    @arunajain9515 6 месяцев назад +1

    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

  • @pradeepravi9608
    @pradeepravi9608 2 года назад +1

    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

  • @deepthimurali962
    @deepthimurali962 2 года назад +2

    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

  • @gayatrichaudhari4306
    @gayatrichaudhari4306 Год назад +1

    We can use distinct keywords for marks

  • @nsnreddy4147
    @nsnreddy4147 6 месяцев назад

    Could you please share with us excel sheet for practicing?

    • @thedatamillennials
      @thedatamillennials  6 месяцев назад

      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 Год назад +1

    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 Год назад +1

    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 Год назад +1

    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  Год назад +1

      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

  • @tejindersingh4580
    @tejindersingh4580 6 месяцев назад +1

    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