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)那里返回所有的记录,即使在右表( ...
随机推荐
- 【WPF】自定义控件之远程图片浏览
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...
- 转:Exploiting Windows 10 in a Local Network with WPAD/PAC and JScript
转:https://googleprojectzero.blogspot.com/2017/12/apacolypse-now-exploiting-windows-10-in_18.html aPA ...
- 【BZOJ 1853】 1853: [Scoi2010]幸运数字 (容斥原理)
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2472 Solved: 911 Description 在中国 ...
- 【BZOJ 3133】 3133: [Baltic2013]ballmachine (线段树+倍增)
3133: [Baltic2013]ballmachine Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 148 Solved: 66 Descri ...
- [ZOJ3254] MON 9.2009Secret Code
A^x = D (mod P) 0 <= x <= M, here M is a given integer. 1 <= A, P < 2^31, 0 <= D < ...
- 多个Fragment在屏幕翻转会重影问题的解决
fragment使用add和hide而不用replace的方法添加到activity中,如果屏幕翻转可能会又add新的fragment进去,所以会重影. 如果有一个sparsearray保存fragm ...
- SpringBoot 如何从前台传递数组
1.SpringBoot 如何从前台传递数组 2.前台 $.ajax({ url: 'deleteBsGiftById', type: 'post', dataType: 'json', data: ...
- 2015 UESTC 数据结构专题C题 秋实大哥与快餐店 字典树
C - 秋实大哥与快餐店 Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/59 ...
- linux基础命令学习 (八)磁盘空间
一.df linux中df命令的功能是用来检查linux服务器的文件系统的磁盘空间占用情况.于du不同的是,du是面向文件的命令,只计算被文件占用的空间.不计算文件系统metadata 占用的空间.d ...
- Android中的数据存储(二):文件存储 2017-05-25 08:16 35人阅读 评论(0) 收藏
文件存储 这是本人(菜鸟)学习android数据存储时接触的有关文件存储的知识以及本人自己写的简单地demo,为初学者学习和使用文件存储提供一些帮助.. 如果有需要查看SharedPreference ...