当前位置:网站首页>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 .
边栏推荐
- [openvino+paddle] paddle detection / OCR / SEG export based on paddle2onnx
- Arc135 a (time complexity analysis)
- 一键过滤选择百度网盘文件
- Review | categories and mechanisms of action of covid-19 neutralizing antibodies and small molecule drugs
- My NVIDIA developer journey - optimizing graphics card performance
- Configure cross compilation tool chain and environment variables
- Nexus 6p downgraded from 8.0 to 6.0+root
- 746. Climb stairs with minimum cost
- How to determine whether an array contains an element
- Detectron: train your own data set -- convert your own data format to coco format
猜你喜欢
My NVIDIA developer journey - optimizing graphics card performance
[excel] PivotChart
Gridview出现滚动条,组件冲突,如何解决
js如何将秒转换成时分秒显示
Error CVC complex type 2.4. a: Invalid content beginning with element 'base extension' was found. Should start with one of '{layoutlib}'.
JS execution mechanism
Halcon image calibration enables subsequent image processing to become the same as the template image
Take you to quickly learn how to use qsort and simulate qsort
Grounding relay dd-1/60
Actual cases and optimization solutions of cloud native architecture
随机推荐
剑指 Offer II 038. 每日温度
How much computing power does transformer have
C语言练习题(递归)
Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?
QT QTableWidget 表格列置顶需求的思路和代码
ES6 modularization
How to realize multi account login of video platform members
746. Climb stairs with minimum cost
C language - Blue Bridge Cup - Snake filling
STC8H开发(十二): I2C驱动AT24C08,AT24C32系列EEPROM存储
High performance parallel programming and optimization | lesson 02 homework at home
冲击继电器JC-7/11/DC110V
AWT common components, FileDialog file selection box
检漏继电器JY82-2P
测试岗的中年危机该如何选择?是坚守还是另寻出路?且看下文
One click filtering to select Baidu online disk files
C语言中的函数(详解)
buuctf-pwn write-ups (8)
Experience weekly report no. 102 (July 4, 2022)
Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式