SQL Join 3 Tables: How-To with Example

Поділитися
Вставка

КОМЕНТАРІ • 111

  • @scottgee3089
    @scottgee3089 2 роки тому +13

    This video saved me. You explained this better than a text book, 15 minutes video, and a lecture from my prof combined did. Thank you

  • @bhumikalamba186
    @bhumikalamba186 2 роки тому +11

    Thanks for the lucid explanation.
    Summary:
    1. SELECT columns to show from the first table
    2. (INNER/OUTER) JOIN to the second table
    3. add the columns to join ON
    4. add any additional columns to step 1.
    5. (INNER/OUTER) JOIN to third table
    6.add the columns to join ON . The columns can belong to the first/second table and then join it with the column for the third table
    7. add any additional columns to step 1.

  • @kalenwilson3319
    @kalenwilson3319 2 роки тому +5

    I have been trying to make sense of joins for the past 4 weeks - but the very essence of it had eluded me. NOW I understand! Thank you for simplifying this to the point where even I could understand it!

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Thanks! I'm glad you found it useful and are able to understand it!

  • @bebe4235
    @bebe4235 Рік тому +2

    hours upon hours of trying to figure this stuff out and your short video was all i needed. wish I could have found it sooner. THANKS!!

  • @jeanettemartinez8
    @jeanettemartinez8 Рік тому +1

    Thank you! I have watched so many videos where I get completely lost. I was able to follow along in the order and understand how! I really appreciate you and the method you teach.

    • @DatabaseStar
      @DatabaseStar  Рік тому +1

      Thanks! Glad it helped you understand it.

  • @BensLab
    @BensLab 2 роки тому +1

    Thank You! I've been banging my head against a wall trying to figure this out. This video finally helped me. Many many thanks!

  • @akutiaakuti3608
    @akutiaakuti3608 2 місяці тому

    Clear and simple presentation, thank you very much

  • @vanpham4691
    @vanpham4691 2 роки тому +5

    Extremely easy to understand. Thank you so much for this!!!!

  • @jordiadistira
    @jordiadistira 4 місяці тому +1

    Thank you so much! Just 2 words, "Amazing Explanation"

  • @damisohutchinson1832
    @damisohutchinson1832 3 роки тому +2

    Ive been rattling my brain for over an hour...to do what you did in 4:05....thank you

  • @petecarroll7807
    @petecarroll7807 2 роки тому

    Thank you sir, could not have finished my MySQL project without. Thank you!!!!!!!!!

  • @NOLONGERANONYMOUS
    @NOLONGERANONYMOUS 2 роки тому +1

    Needed to turn a setting off on certain records in one table based off of a category stored in another table. I'm just beginning to learn SQL for my job and this helped!

  • @zabialy2919
    @zabialy2919 Рік тому

    Great video, still very relevant after 2 years!

  • @hashanhemachandra4832
    @hashanhemachandra4832 Рік тому

    Thanks so much! This saved me! Love from Sri Lanka

  • @lilbandit1979
    @lilbandit1979 3 роки тому

    Thank you, thank you, thank you!!! Very clear!

  • @patyue5012
    @patyue5012 3 роки тому

    Thanks for the illustrated example

  • @caryharris2358
    @caryharris2358 2 роки тому

    Saved my life with this one

  • @jorhannyv3142
    @jorhannyv3142 9 місяців тому

    You are a life saver, I am assuming this can be applied for even more than 3 tables, I definitely need to master MySQL for college projects, tysm.

    • @DatabaseStar
      @DatabaseStar  9 місяців тому

      Thanks! Yes you can use the same process for as many tables as you need.

  • @cfurnell6338
    @cfurnell6338 3 роки тому +1

    Thanks looks so easy now, well explained

  • @elisamutiofficial2245
    @elisamutiofficial2245 Рік тому

    i enjoyed the video.thank you dad

  • @devplus7131
    @devplus7131 3 роки тому +1

    Thanks, very easy to understand. :D

  • @sgr7ss
    @sgr7ss 7 місяців тому

    Great explanation

  • @alwaysbehappy1337
    @alwaysbehappy1337 3 роки тому

    It really helpful. Thanks

  • @The.Wellerman
    @The.Wellerman 2 роки тому

    Thank you thank you! This helped me with a project for school. Thank you a ton!

    • @DatabaseStar
      @DatabaseStar  2 роки тому +1

      Awesome! Glad it helped.

    • @The.Wellerman
      @The.Wellerman 2 роки тому +1

      @@DatabaseStar I ended up passing the project. Again, thank you.

  • @SZU1881
    @SZU1881 10 місяців тому

    Fantastic! Thank you!

  • @samplaying4keeps
    @samplaying4keeps 5 місяців тому

    Thank you so much!

  • @camilomezu5008
    @camilomezu5008 3 роки тому

    THANK YOU SO MUCH!

  • @GreenSlugg
    @GreenSlugg 2 роки тому

    Thank you!

  • @redlobsta1
    @redlobsta1 2 роки тому +7

    it would be great if you could include what the tables originally looked like and how they look after each statement.

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Thanks for the feedback! I’ll keep that in mind for future videos. I’ll see if I can add something for this to the Description area.

  • @velinandreev173
    @velinandreev173 2 роки тому

    Lifesaver thank you sooooo much

  • @liatarachel
    @liatarachel 3 роки тому +3

    Really specific and helpful,thank you

  • @sunstryder
    @sunstryder 11 місяців тому

    Mate I wish I had this back in uni.

    • @DatabaseStar
      @DatabaseStar  11 місяців тому

      Thanks! Yeah me too, I’m glad it’s helping many people.

  • @jakebrown1879
    @jakebrown1879 2 роки тому

    I learned something new

  • @darcyyun6122
    @darcyyun6122 2 роки тому

    Very helpful, thankyouuuu

  • @ashfaqmahmud
    @ashfaqmahmud 2 роки тому

    thanks a lot ❤️

  • @xeskan
    @xeskan 3 роки тому +2

    The diagram at the beginning of the table is misleading. It shows it as A join B, B join C and A join C. The query however is just two joins, A join B, A join C. I was expecting the video to be dealing with a circular join. Thank you and keep them good videos on complex data modeling concepts coming.

    • @DatabaseStar
      @DatabaseStar  3 роки тому +1

      That's a good point! I can update the thumbnail to make it clearer (I don't think I can update the video), but this is good to know.

  • @Metanfetamino-san
    @Metanfetamino-san Рік тому

    thanks to your video

  • @AM-Boluke1210
    @AM-Boluke1210 4 місяці тому

    Thank u 👍

  • @victorwestmann
    @victorwestmann 2 роки тому +2

    Is this standard SQL, PL/SQL or T-SQL? Or it does not matter? :-) Thanks for the video! I just failed an interview with this EXACT question. Feeling awful. But life goes on!

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      This is standard SQL. The inner join, left join, and right join are all part of the SQL standard. There are some extra join features in specific database types, but I don't think I mentioned any of them in this video.

  • @gauravsrivastava17
    @gauravsrivastava17 Місяць тому

    Steps make it so easier
    Step 5

  • @fy8331
    @fy8331 2 місяці тому

    Excuse me Sir I have a question. So in step 5 and 6, when joining the 3rd table and later specifying the target columns, suppose now I want to join based on the columns on the 2nd table & the 3rd table, not the 1st table & the 3rd table. What decides which join type to use? In this case does the sequence of specifying table names matter? What if there're more than 3 tables? Thank you in advance!

    • @DatabaseStar
      @DatabaseStar  2 місяці тому

      Good questions!
      - When joining the 3rd table, you can join to any column in either the 1st table or 2nd table. It depends on how you write the query and add the columns and what makes sense for your data.
      - The results that you need will determine the join type to use. I see either an INNER JOIN or LEFT JOIN most commonly, depending on whether you want to see rows that have matches or not.
      - The sequence that you specify the tables will not matter for an INNER JOIN, but it will matter for a LEFT JOIN and RIGHT JOIN.
      - If there are more than 3 tables, you repeat the process: join to table 4, then specify the join condition to either table 1, 2, or 3.

    • @fy8331
      @fy8331 2 місяці тому

      @@DatabaseStar Thank you Sir for your answers, it makes sense! And thank u for your prompt reply!

  • @hassanpatel3630
    @hassanpatel3630 2 роки тому

    I’m using SQL management server and I need with the scenario, I have table A, junction table and Table B I need one row for table A and concatenate multiple rows of table b into one row with a comma. I’ve search the hours and can find no clues at all. I’d really appreciate it if you help me out

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Hey, I think you would need to use a technique called “string aggregation”. This is done using a function called string_agg in sql server. If you have the right results in separate rows showing for table a and b, you can then use this function to combine rows from table b into one row.

  • @rapo107
    @rapo107 Рік тому

    Hello sir... Thanks for making this video. Result will get change if order of the tables changes? Pls reply. 🙏

    • @DatabaseStar
      @DatabaseStar  Рік тому

      Thanks! No, the result should stay the same if you are using an Inner Join. If you're using an outer join (e.g. left join or right join) then yes the result will change.

    • @rapo107
      @rapo107 Рік тому

      @@DatabaseStar.. Thank you sir.

  • @saucegayuchiha8816
    @saucegayuchiha8816 2 роки тому +1

    How to add table with different column name

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      You should be able to use the same process. You can specify the column name in the ON clause of the join. For example, if table 2 has a column called some_other_id: JOIN table2 ON table1.id = table2.some_other_id

  • @deesee3622
    @deesee3622 Рік тому

    is language id the same number as publisher id in your example??

    • @DatabaseStar
      @DatabaseStar  Рік тому

      No, in this example they are different fields.

    • @deesee3622
      @deesee3622 Рік тому

      @@DatabaseStar so how are they equal to each other if they are not the same number type?

  • @skeeterstudies8109
    @skeeterstudies8109 Рік тому

    Please I did some but data do not display in the table

    • @DatabaseStar
      @DatabaseStar  Рік тому

      It could be because there is no matches based on your join criteria

    • @skeeterstudies8109
      @skeeterstudies8109 Рік тому

      @@DatabaseStar thank you very much, it is now working

  • @sukumarpadhi8426
    @sukumarpadhi8426 2 роки тому

    How about show the result in a final form? Your title says with example. However no example....

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      The final result is shown from about 3:16 where the query has fields from three different tables, which is the example. Were you looking for something else?\

    • @OBERE_
      @OBERE_ 6 місяців тому

      Like how can i get my tittle

  • @wendya2309
    @wendya2309 2 роки тому

    hm, I am getting "ambiguous column name" error.

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Ah that’s because the column name exists in more than one table and the database does not know which column you want. If you add the table name and a . Before the column it should work. Eg customer.firstname instead of just firstname.

    • @wendya2309
      @wendya2309 2 роки тому

      That worked! Thanks for responding and clarifying!

  • @Moccalocca100
    @Moccalocca100 9 місяців тому

    This query wouldnt work lol

    • @DatabaseStar
      @DatabaseStar  9 місяців тому

      Oh, what error are you getting?

  • @X-Agn
    @X-Agn 2 роки тому

    Lol show inner with left join . Don't show easy one

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Good point. Left join would be the same query with Left instead of Inner. But the results would be different

  • @omarto7414
    @omarto7414 2 роки тому

    Thank you!