当前位置:网站首页>What is SQL get connection
What is SQL get connection
2022-07-03 18:21:00 【Xiao Wang next door to you】
Written above
- Author's brief introduction : Hello everyone , I'm Xiao Wang *️
- Personal home page : Xiao Wang next door to you
- Welcome to thumb up + Collection ️+ Leaving a message.
- special column :SQL*️
*️ If you have something you don't understand in the process of learning , Welcome to the comment area to leave a message and ask questions ! I hope I can make progress with you , Grow up together !
Catalog
coupling ( Join tables in columns )
Internal connection —— INNER JOIN
Extraneous junction —— OUTER JOIN
3 The connection of the above tables
coupling ( Join tables in columns )
● coupling ( JOIN ) Is to add columns from other tables , Conduct “ Add columns ” Set operation of .UNION It's to do ( The longitudinal ) Operate for units , And the connection is by column ( The transverse ) In units .
● Connections are generally divided into internal connections and external connections . First of all, please firmly grasp the use of these two connections .
What is connection
- coupling ( JOIN ) Simply speaking , Is to add columns from other tables , Conduct “ Add columns ” Arithmetic , By using joins, you can select data from multiple tables
Internal connection —— INNER JOIN
surface 1
surface 2
As shown in the table above , The columns in the two tables can be divided into the following two categories
The so-called connection operation , In a word , Namely “ With A Columns in serve as bridges , take B The columns that meet the same conditions in are collected into the same result ”
SELECT SP.shop_id, SP.shop_name, SP.product_id, P.product_name, P.sale_price FROM ShopProduct AS SP INNER JOIN Product AS P ON SP.product_id = P.product_id;
You can find that the two tables are combined (ps: You must use ON Clause , And write in FROM and WHERE Between , When using connections SELECT The columns in the clause need to follow “ < The table alias > . < Name > ” Write in the format of .)
Extraneous junction —— OUTER JOIN
Outreach is also through ON The join key of clause joins the two tables , And select the corresponding columns from the two tables at the same time . The basic method of use is no different , But the result is different .
SELECT SP.shop_id, SP.shop_name, SP.product_id, P.product_name, P.sale_price FROM ShopProduct AS SP RIGHT OUTER JOIN Product AS P ON SP.product_id = P.product_id;
Inline join can only select data that exists in two tables at the same time , For outreach , As long as the data exists in a table , Can read out , The final result will include all the data in the main table . The key to specify the main table is LEFT and RIGHT . seeing the name of a thing one thinks of its function , Use LEFT when FROM The table written on the left in the clause is the main table , Use RIGHT The table on the right is the main table
3 The connection of the above tables
surface 3
SELECT SP.shop_id, SP.shop_name, SP.product_id, P.product_name, P.sale_price, IP.inventory_quantity FROM ShopProduct AS SP INNER JOIN Product AS P ON SP.product_id = P.product_id INNER JOIN InventoryProduct AS IP ON SP.product_id = IP.product_id WHERE IP.inventory_id = 'S001';
Cross connect —— CROSS JOIN
Cross join is the basis of all join operations .
SELECT SP.shop_id, SP.shop_name, SP.product_id, P.product_name FROM ShopProduct AS SP CROSS JOIN Product AS P;
The set operator to cross join tables that meet the same rules is CROSS JOIN ( Cartesian product ). You cannot use the... Used in inner and outer joins when making cross joins ON Clause , This is because cross join is the cross combination of all records in two tables , So the number of records in the result is usually the product of the number of rows in two tables .
An inline connection is part of a cross connection ,“ Inside ” It can also be understood as “ The part contained in the cross join result ”. contrary , Extraneous “ Outside ” It can be understood as “ The part beyond the cross connect result ”.

边栏推荐
- A. Odd Selection【BruteForce】
- 2022-2028 global sepsis treatment drug industry research and trend analysis report
- AcWing 271. Teacher Yang's photographic arrangement [multidimensional DP]
- What problems can cross-border e-commerce sellers solve with multi platform ERP management system
- [combinatorics] exponential generating function (proving that the exponential generating function solves the arrangement of multiple sets)
- 199. Right view of binary tree - breadth search
- 微服务组件Sentinel控制台调用
- 2022-2028 global copper foil (thickness 12 μ M) industry research and trend analysis report
- 网格图中递增路径的数目[dfs逆向路径+记忆dfs]
- BFS - topology sort
猜你喜欢

Computer graduation design PHP sports goods online sales system website

模块九作业

Talk about the design and implementation logic of payment process

win32:堆破坏的dump文件分析

Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition

2022-2028 global plasmid DNA cdmo industry research and trend analysis report

What problems can cross-border e-commerce sellers solve with multi platform ERP management system
![[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)](/img/e6/9880e708aed42dc82c94aea002020c.jpg)
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)

2022-2028 global lithium battery copper foil industry research and trend analysis report

Nodejs (01) - introductory tutorial
随机推荐
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation)
网格图中递增路径的数目[dfs逆向路径+记忆dfs]
Keepalived 设置不抢占资源
The second largest gay dating website in the world was exposed, and the status of programmers in 2022
A. Odd Selection【BruteForce】
Ssl/bio of OpenSSL_ get_ fd
PHP MySQL reads data
2022-2028 global aircraft head up display (HUD) industry research and trend analysis report
2022-2028 global petroleum pipe joint industry research and trend analysis report
The vscode code is automatically modified to a compliance code when it is formatted and saved
How to deploy applications on kubernetes cluster
小程序 多tab 多swiper + 每个tab分页
Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition
Win32: analyse du fichier dump pour la défaillance du tas
supervisor监控Gearman任务
2022-2028 global plasmid DNA cdmo industry research and trend analysis report
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
[combinatorics] generating function (summation property)
2022-2028 global sepsis treatment drug industry research and trend analysis report
Image 24 bit depth to 8 bit depth









