当前位置:网站首页>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 ”.
边栏推荐
- Talk about the design and implementation logic of payment process
- Unsafe类的使用
- [Yu Yue education] family education SPOC class 2 reference materials of Shanghai Normal University
- PHP MySQL inserts data
- 企业级自定义表单引擎解决方案(十二)--表单规则引擎2
- 【统信UOS】扫描仪设备管理驱动安装
- Module 9 operation
- Ssl/bio of OpenSSL_ get_ fd
- 2022-2028 global scar care product industry research and trend analysis report
- BFS - topology sort
猜你喜欢
Sensor 调试流程
win32:堆破壞的dump文件分析
基于人脸识别的课堂考勤系统 tkinter+openpyxl+face_recognition
Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
2022-2028 global sepsis treatment drug industry research and trend analysis report
Summary and Reflection on the third week of winter vacation
2022-2028 global solid phase extraction column industry research and trend analysis report
Three gradient descent methods and code implementation
Naoqi robot summary 27
Redis on local access server
随机推荐
Golang string (string) and byte array ([]byte) are converted to each other
Keepalived 设置不抢占资源
How to draw non overlapping bubble chart in MATLAB
Change the single node of Postgres database into master-slave
Records of long objects and long judgments in the stream of list
English語法_名詞 - 分類
OpenSSL的SSL/BIO_get_fd
A. Odd Selection【BruteForce】
Unsafe类的使用
Computer graduation design PHP campus address book telephone number inquiry system
2022-2028 global marking ink industry research and trend analysis report
2022-2028 global sepsis treatment drug industry research and trend analysis report
[Godot] add menu button
Image 24 bit depth to 8 bit depth
The number of incremental paths in the grid graph [dfs reverse path + memory dfs]
Computer graduation design PHP makeup sales Beauty shopping mall
Ml (machine learning) softmax function to realize the classification of simple movie categories
How to track the real-time trend of Bank of London
Prototype inheritance..
Graduation summary