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 |
SQL INNER JOIN的更多相关文章
- 图解SQL的Join 转自coolshell
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...
- 图解SQL的Join(转)
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...
- SQL JOIN\SQL INNER JOIN 关键字\SQL LEFT JOIN 关键字\SQL RIGHT JOIN 关键字\SQL FULL JOIN 关键字
SQL join 用于根据两个或多个表中的列之间的关系,从这些表中查询数据. Join 和 Key 有时为了得到完整的结果,我们需要从两个或更多的表中获取结果.我们就需要执行 join. 数据库中的表 ...
- 关于sql中join
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...
- 图解SQL的Join(转摘)
转摘网址:http://coolshell.cn/articles/3463.html 对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的 ...
- SQL RIGHT JOIN 关键字
SQL RIGHT JOIN 关键字 RIGHT JOIN 关键字会右表 (table_name2) 那里返回所有的行,即使在左表 (table_name1) 中没有匹配的行. RIGHT JOIN ...
- SQL LEFT JOIN 关键字
SQL LEFT JOIN 关键字 LEFT JOIN 关键字会从左表 (table_name1) 那里返回所有的行,即使在右表 (table_name2) 中没有匹配的行. LEFT JOIN 关键 ...
- SQL 连接 JOIN 例解。(左连接,右连接,全连接,内连接,交叉连接,自连接)
SQL 连接 JOIN 例解.(左连接,右连接,全连接,内连接,交叉连接,自连接) 最近公司在招人,同事问了几个自认为数据库可以的应聘者关于库连接的问题,回答不尽理想-现在在这写写关于它们的作用假设有 ...
- SQL Server Join方式
原文:SQL Server Join方式 0.参考文献 Microsoft SQL Server企业级平台管理实践 看懂SqlServer查询计划 1.测试数据准备 参考:Sql Server中的表访 ...
- SQL的JOIN语法解析(inner join, left join, right join, full outer join的区别)
原文链接:http://www.powerxing.com/sql-join/ 总的来说,四种JOIN的使用/区别可以描述为: left join 会从左表(shop)那里返回所有的记录,即使在右表( ...
随机推荐
- img标签src图片地址找不到显示默认图片
可以采用onerror的属性: onerror="javascript:this.src='${base}/after/img/aifu.png'" <img id=&quo ...
- HDU 6031 Innumerable Ancestors
树状数组,倍增,枚举,$dfs$序. 对于每一次的询问,可以枚举$B$集合中的所有点,对于每一个点,在树上二分$LCA$,找到最低的更新答案. 判断是否是$LCA$可以搞个$dfs$序,将$A$集合中 ...
- BNUOJ 52503 Disdain Chain
暴力,结论. 本打算写一发暴力,然后直接交答案,之后发现无论$n$等于多少,每种图都存在长度为$n$的路径,中间还一直以为自己暴力写错了. #include<bits/stdc++.h> ...
- 首次使用ideal构建maven项目web
如附件 链接:https://pan.baidu.com/s/1oH-9VfIKnLPjVt-tOH7fZw 提取码:7s5t
- post登录趴一趴百度贴吧美女
本次爬取的贴吧是百度的美女吧,给广大男同胞们一些激励 在爬取之前需要在浏览器先登录百度贴吧的帐号,各位也可以在代码中使用post提交或者加入cookie 爬行地址:http://tieba.baidu ...
- 【BZOJ 4665】 4665: 小w的喜糖 (DP+容斥)
4665: 小w的喜糖 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 94 Solved: 53 Description 废话不多说,反正小w要发喜 ...
- 【BZOJ 2669】 2669: [cqoi2012]局部极小值 (状压DP+容斥原理)
2669: [cqoi2012]局部极小值 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 667 Solved: 350 Description 有一 ...
- bzoj 3944 杜教筛
题目中要求phi和miu的前缀和,利用杜教筛可以推出公式.我们令为 那么有公式 类比欧拉函数,我们可以推出莫比乌斯函数的和公式为 (公式证明懒得写了,主要核心是利用Dirichlet卷积的性质 ph ...
- Stirling数,Bell数,Catalan数,Bernoulli数
组合数学的实质还是DP,但是从通式角度处理的话有利于FFT等的实现. 首先推荐$Candy?$的球划分问题集合: http://www.cnblogs.com/candy99/p/6400735.ht ...
- [CodeForces-440D]Berland Federalization
题目大意: 给你一棵树,你可以删掉一些边,使得分除去的子树中至少有一棵大小为k. 问最少删去多少边,以及删边的具体方案. 思路: 树形DP. f[i][j]表示以i为根,子树中去掉j个点最少要删边的数 ...