当前位置:网站首页>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 ”.

边栏推荐
- 2022-2028 global marking ink industry research and trend analysis report
- OpenSSL的SSL/BIO_get_fd
- Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries
- [Yu Yue education] family education SPOC class 2 reference materials of Shanghai Normal University
- Win 11 major updates, new features love love.
- A. Berland Poker &1000【简单数学思维】
- 2022-2028 global aircraft head up display (HUD) industry research and trend analysis report
- Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
- 2022-2028 global sepsis treatment drug industry research and trend analysis report
- Market demand survey and marketing strategy analysis report of global and Chinese pet milk substitutes 2022-2028
猜你喜欢

Have you learned the correct expression posture of programmers on Valentine's day?

(9) Opencv Canny edge detection

模块九作业
![[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)

Global and Chinese health care OEM and ODM market status survey and investment planning recommendations report 2022-2028

Naoqi robot summary 27

What London Silver Trading software supports multiple languages

PHP MySQL inserts data

AcWing 271. 杨老师的照相排列【多维DP】

Redis on local access server
随机推荐
Theoretical description of linear equations and summary of methods for solving linear equations by eigen
2022-2028 global plasmid DNA cdmo industry research and trend analysis report
小程序 多tab 多swiper + 每个tab分页
Kotlin's collaboration: Context
English grammar_ Noun classification
A. Odd Selection【BruteForce】
Summary and Reflection on the third week of winter vacation
Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
Valentine's day, send you a little red flower~
Sensor 调试流程
The vscode code is automatically modified to a compliance code when it is formatted and saved
Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
The second largest gay dating website in the world was exposed, and the status of programmers in 2022
A. Odd Selection【BruteForce】
Install apache+php+mysql+phpmyadmin xampp and its error resolution
Golang string (string) and byte array ([]byte) are converted to each other
English語法_名詞 - 分類
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
PHP MySQL where clause
Line by line explanation of yolox source code of anchor free series network (6) -- mixup data enhancement









