Understanding SQL Joins

  • I Need some help! I'm New and learning SQL I have the basics of SQL down but I need some help with Joins more specifically Inner Joins with linking multiple tables.

    If someone can please provide some good Sites for me to review that would be great.

    Also if someone can offer some samples that I can use with the Northwind DB I would appreciate it!

    TIA!!

  • Start here: http://www.sqlservercentral.com/stairway/75773/[/url].

    Also, download and insstall the AdventureWorks sample database. Though far from perfect, it's a much better test- and play-ground than Northwind.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Sweetbee870 (1/8/2016)


    I Need some help! I'm New and learning SQL I have the basics of SQL down but I need some help with Joins more specifically Inner Joins with linking multiple tables.

    If someone can please provide some good Sites for me to review that would be great.

    Also if someone can offer some samples that I can use with the Northwind DB I would appreciate it!

    TIA!!

    Simple Venn Join diagram to get you started

    😎

  • Thank you! I appreciate the help!

    I do have a question when joining multiple tables together I do know we use the like fields within each table. As you add in more tables with like fields do you use the like fields from the last table joined when adding in another table join?

    I understand doing simple simple joins. I start to get a little lost when adding in more tables to the query.

    I hope I explained this correctly.

    I will see if I can find an example of what I mean.

    Thank you for your help!

  • Sweetbee870 (1/14/2016)


    Thank you! I appreciate the help!

    I do have a question when joining multiple tables together I do know we use the like fields within each table. As you add in more tables with like fields do you use the like fields from the last table joined when adding in another table join?

    I understand doing simple simple joins. I start to get a little lost when adding in more tables to the query.

    I hope I explained this correctly.

    I will see if I can find an example of what I mean.

    Thank you for your help!

    When you add more tables to the FROM clause, you join them to whatever other table they actually relate to. The join conditions always follow logically from the requirements and from the relationships between the data. So if you have a join between students and course-enrollments, and you'd have to add information about students' addresses, you would join the Address table to the Students table. But if you needed to provide the location where classes are taught, you would join the enrollments table to the Courses table (assuming that you have the classroom stored there).

    The order in which you write out the joins is actually irrelevant, as long as certain syntax rules are followed.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply