SQL Joins: A Guide and Examples

Поділитися
Вставка
  • Опубліковано 25 лип 2024
  • 📝 Get my free SQL Cheat Sheets: www.databasestar.com/get-sql-...
    🎓 Learn and become confident in SQL: databasestar.mykajabi.com/sql...
    SQL joins are a commonly used feature when writing queries. They let you combine two (or more) tables together in your SQL query and see a single set of results.
    In this video, you'll learn a bit more about what SQL joins are, why they are needed, the different types of joins, and examples of each in a SELECT query.
    I'll also share a few tips on working with joins and things to avoid.
    Related videos:
    How to Join 3 Tables: • SQL Join 3 Tables: How...
    Self Joins: • Self Join in SQL
    Timestamps:
    00:00 Start
    00:16 What is a join?
    00:48 Sample tables
    01:38 Start of query
    01:58 Inner Join
    04:49 Left Outer Join
    06:10 Right Outer Join
    07:10 Full Outer Join
    07:38 Joins are not bad
    08:16 Using keyword
    08:46 Natural Join
    09:17 Joins in a Where clause
  • Наука та технологія

КОМЕНТАРІ • 30

  • @anjumshaikh7735
    @anjumshaikh7735 11 місяців тому +7

    I just love the way you break down the hardest topics & concepts so clear , easy to understand with simple examples . Thank you so much. ❤❤❤❤

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

      Thanks! I’m glad you enjoyed the video and we’re able to understand the concepts from it.

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

    Extra thanks for the subtitles! Even if I don't have a listening issue, they help understanding better

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

      Thanks! Glad to hear they are helpful for you.

  • @sambarjunk
    @sambarjunk Рік тому +3

    Clear and to the point

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

    This video was so helpful. Thank you!

  • @RainNColer
    @RainNColer Рік тому +3

    Damn im learning selftaught full stack development and already learned MERN stack but felt the need to learn SQL, and im loving it, this channel is so crystal clear with all the topics that i encounter when practicing with my project and want to learn. A great thing about SQL is that is an ancient concept and will prevail even longer so all this information will be valuable for years to come :)

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

      Thanks for the kind words, and I'm glad to hear my videos are helpful. Yeah, SQL has been around for a while and the fundamentals don't change.

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

    Thanks keep making content like this

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

    Thank you.

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

    Thanks!

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

    helpful, keep it up

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

    can we do joins without foreignkey?

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

      Yes, you can. As long as the fields in both tables represent the same thing, you can do a join and there does not have to be a foreign key created.

  • @RDL-yw5wy
    @RDL-yw5wy 3 місяці тому

    Thank you
    sorry I didn't find a link of the video that contains join three tables or more

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

      No problem, the link is here: ua-cam.com/video/TGt2xa7EzvI/v-deo.html

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

    super awesome

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

    can we really join without foreign key -- primary key relation?

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

      Yeah, you can. You would usually join between PK and FK, but you don't need to have those constraints to make the join work. If both columns represent the same thing then you can join.
      You can actually join on two columns that have two different sets of data, but your results will not be meaningul.

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

    So correct me if I'm wrong these two tables break referential integrity rules, but joins still possible?

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

      What about these tables breaks referential integrity rules? In general, you can still join tables if they break rules like that, as long as the data being joined is the same (e.g. both IDs or names or values represent the same thing)

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

      @@DatabaseStar So I can create a record in a child table not related to to a parent table record.

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

      Yes, that's right, you can. If you leave the foreign key empty the row will still be inserted. You could put a Not Null constraint on it to prevent that though.