zoukankan      html  css  js  c++  java
  • SQL INNER JOIN

    A INNER JOIN command is queries that combine data from more than 1 table.
    For two tables that want to join together need to have some data in common, like unique id that link this 2 tables together.

    INNER JOIN will need a joining condition or connecting column to display out the joined data. 1 joining condition needs when we want to join 2 tables. If more than 2 tables want to join together, more joining condition or connecting column needed.

    A connecting column should have values that match easily for both tables. Connecting columns almost always have the same datatype. The value in the connecting columns are join compatible or can say that the value are come from the same general class of data.

    SQL INNER JOIN syntax:

    SELECT *FROM [TABLE 1] INNER JOIN [TABLE 2]
    ON [TABLE 1].[COLUMN NAME 1] = [TABLE 2].[COLUMN NAME 2]


    EXAMPLE :

    Let’s say, we only want to join 2 tables below and display only PlayerName and DepartmentName

    Table 1: GameScores

    PlayerName DepartmentId Scores
    Jason 1 3000
    Irene 1 1500
    Jane 2 1000
    David 2 2500
    Paul 3 2000
    James 3 2000

    Table 2: Departments

    DepartmentId DepartmentName
    1 IT
    2 Marketing
    3 HR

    The joining Condition will be DepartmentId of both tables.
    SQL statement :

    SELECT PlayerName, DepartmentName
    FROM GameScores2 INNER JOIN Departments
    ON GameScores2.DepartmentId = Departments.DepartmentId

    Result:

    PlayerName DepartmentName
    Jason IT
    Irene IT
    Jane Marketing
    David Marketing
    Paul HR
    James HR
  • 相关阅读:
    PowerTalk第一个版本儿控件
    PowerTalk第二个版本,支持(Msn回复信息)
    自然语言处理著作或期刊名称
    自然语言处理(NLP)网上资源整理 (转)
    TFIDF
    计算机科学及工程
    自然语言处理与计算语言学书籍汇总之一:国外书籍
    UVa 10696 f91
    缓存
    操作必须使用一个可更新的查询(转)
  • 原文地址:https://www.cnblogs.com/zhoug2020/p/3327817.html
Copyright © 2011-2022 走看看