当前位置:网站首页>SQL join, left join, right join usage
SQL join, left join, right join usage
2022-07-04 06:11:00 【Game programming】
SQL Join Used to combine rows from two or more tables , Based on the common fields between these tables .
INNER JOIN: If there is at least one match in the table , Then go back to the line
LEFT JOIN: Even if there is no match in the right table , Also returns all rows from the left table
RIGHT JOIN: Even if there is no match in the left table , Also returns all rows from the right table
FULL JOIN: As long as there is a match in one of the tables , Then go back to the line
grammar
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
perhaps :
SELECT column_name(s)
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;
INNER JOIN And JOIN It's the same .
Refer to the figure below :

LEFT JOIN Keywords from the left table (table1) Go back to all the lines , Even if the right watch (table2) There is no match in . If there is no match in the right table , The result is NULL.
grammar
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
or :
SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;
In some databases ,LEFT JOIN be called LEFT OUTER JOIN.
RIGHT JOIN Keywords from the right table (table2) Go back to all the lines , Even if the left watch (table1) There is no match in . If there is no match in the left table , The result is NULL.
grammar
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;
or :
SELECT column_name(s)
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;
In some databases ,RIGHT JOIN be called RIGHT OUTER JOIN.
FULL OUTER JOIN Key words only need left table (table1) And the right watch (table2) There is a match... In one of the tables , Then go back to the line .
FULL OUTER JOIN Keywords combine LEFT JOIN and RIGHT JOIN Result .
grammar
SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;
FULL OUTER JOIN Keyword returns all rows in the left and right tables . If table1 The rows in the table are in table2 There is no match or table2 The rows in the table are in table1 There is no match in the table , These lines will also be listed .
author :Ritchie_Li
this paper [ SQL Join,Left Join,Right Join usage ] Included in Game programming ️ - database , A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome browser .
边栏推荐
- Take you to quickly learn how to use qsort and simulate qsort
- [untitled]
- 如何展开Collapse 的所有折叠面板
- 70000 words of detailed explanation of the whole process of pad openvino [CPU] - from environment configuration to model deployment
- left_ and_ right_ Net normal version
- InputStream/OutputStream(文件的输入输出)
- How to get the parent node of all nodes in El tree
- 如何避免 JVM 内存泄漏?
- lightroom 导入图片灰色/黑色矩形 多显示器
- C language exercises (recursion)
猜你喜欢

InputStream/OutputStream(文件的输入输出)

Actual cases and optimization solutions of cloud native architecture

ABAP:OOALV实现增删改查功能

检漏继电器JY82-2P

Notes and notes

JS arguments parameter usage and explanation

冲击继电器JC-7/11/DC110V

HMS v1.0 appointment. PHP editid parameter SQL injection vulnerability (cve-2022-25491)

Gridview出现滚动条,组件冲突,如何解决

Upper computer software development - log information is stored in the database based on log4net
随机推荐
如何判断数组中是否含有某个元素
webrtc 快速搭建 视频通话 视频会议
px em rem的区别
509. Fibonacci number, all paths of climbing stairs, minimum cost of climbing stairs
JS扁平化数形结构的数组
QT releases multilingual International Translation
实用的小工具指令
JSON Web Token----JWT和传统session登录认证对比
我的NVIDIA开发者之旅——优化显卡性能
746. Climb stairs with minimum cost
Average two numbers
2022.7.2-----leetcode. eight hundred and seventy-one
[Chongqing Guangdong education] electronic circuit homework question bank of RTVU secondary school
C language exercises (recursion)
A little understanding of GSLB (global server load balance) technology
Wechat applet +php realizes authorized login
JS how to convert seconds into hours, minutes and seconds display
Leetcode question brushing record | 206_ Reverse linked list
【微服务】Nacos集群搭建以及加载文件配置
How to realize multi account login of video platform members