当前位置:网站首页>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 ”.
边栏推荐
- Introduction to PHP MySQL
- Self executing function
- [combinatorics] generating function (positive integer splitting | unordered non repeated splitting example)
- Golang string (string) and byte array ([]byte) are converted to each other
- Sensor debugging process
- How to install PHP on Ubuntu 20.04
- Win32: analyse du fichier dump pour la défaillance du tas
- Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
- G1 garbage collector of garbage collector
- PHP MySQL Update
猜你喜欢
English grammar_ Noun classification
Global and Chinese pediatric palliative care drug market development research and investment planning recommendations report 2022-2028
As soon as we enter "remote", we will never regret, and several people will be happy and several people will be sad| Community essay solicitation
English语法_名词 - 分类
Talk about the design and implementation logic of payment process
2022-2028 global petroleum pipe joint industry research and trend analysis report
Redis on local access server
win32:堆破坏的dump文件分析
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
随机推荐
As soon as we enter "remote", we will never regret, and several people will be happy and several people will be sad| Community essay solicitation
ES7 - Optimization of promise
Records of long objects and long judgments in the stream of list
Research on Swift
win32:堆破坏的dump文件分析
Redis on local access server
An academic paper sharing and approval system based on PHP for computer graduation design
Distributed task distribution framework gearman
English语法_形容词/副词3级 - 倍数表达
Self executing function
Supervisor monitors gearman tasks
Mature port AI ceaspectus leads the world in the application of AI in terminals, CIMC Feitong advanced products go global, smart terminals, intelligent ports, intelligent terminals
Codeforces Round #803 (Div. 2) C. 3SUM Closure
[tutorial] build your first application on coreos
Redis core technology and practice - learning notes (IX): slicing cluster
Life perception 1
Sensor 调试流程
Kotlin's collaboration: Context
BFS - topology sort
Three gradient descent methods and code implementation