当前位置:网站首页>[MySQL] sql99 syntax to realize multi table query
[MySQL] sql99 syntax to realize multi table query
2022-07-03 23:19:00 【Charming】
1. SQL92: Use (+) Create connection
stay SQL92 Used in
(+)
Represents the location of the slave table . namelyLeft or right outer connection
in ,(+)
Indicates which is from the table .Oracle
Yes SQL92 Better support , andMySQL
Do not support SQL92 External connection of .Oracle Realization
# The left outer join
SELECT last_name,department_name
FROM employees,departments
WHERE employees.department_id = departments.department_id(+);
# Right connection
SELECT last_name,department_name
FROM employees ,departments
WHERE employees.department_id(+) = departments.department_id;
- SQL92 Syntax to implement inner connection : as follows
practice : Query all employees last_name,department_name Information
SELECT employee_id,department_name
FROM employees e,departments d
WHERE e.`department_id` = d.department_id;
- And in SQL92 in , Only the left outer connection and the right outer connection , Not full ( Or all ) External connection .
2. SQL99 Syntax to implement multi table query
- Use
JOIN...ON
Clause creates the syntax structure of the join : - SQL99 Use... In grammar
JOIN ...ON
To realize the query of multiple tables . This method can also solve the problem of external connection .MySQL It supports this way .
SELECT table1.column, table2.column,table3.column
FROM table1
JOIN table2 ON table1 and table2 The connection condition of
JOIN table3 ON table2 and table3 The connection condition of
- SQL99 Syntax to implement inner connection :
SELECT last_name,department_name
FROM employees e INNER JOIN departments d
ON e.`department_id` = d.`department_id`;
SELECT last_name,department_name,city
FROM employees e JOIN departments d
ON e.`department_id` = d.`department_id`
JOIN locations l
ON d.`location_id` = l.`location_id`;
- SQL99 Syntax implementation external connection :
practice : Query all employees last_name,department_name Information
- The left outer join :
SELECT last_name,department_name
FROM employees e LEFT JOIN departments d
ON e.`department_id` = d.`department_id`;
- Right connection :
SELECT last_name,department_name
FROM employees e RIGHT OUTER JOIN departments d
ON e.`department_id` = d.`department_id`;
- Full outer join :mysql I won't support it
FULL OUTER JOIN
SELECT last_name,department_name
FROM employees e FULL OUTER JOIN departments d
ON e.`department_id` = d.`department_id`;
- SQL99 This nested structure is very refreshing 、 More hierarchical 、 More readable , Even if more tables are connected, they are clearly visible . If you take SQL92, Readability will be greatly reduced .
边栏推荐
- Hcip day 12 notes
- [15th issue] Tencent PCG background development internship I, II and III (OC)
- Pointer concept & character pointer & pointer array yyds dry inventory
- Schematic diagram of crystal oscillator clock and PCB Design Guide
- Go error collection | talk about the difference between the value type and pointer type of the method receiver
- Current detection circuit - including op amp current scheme
- Maxwell equation and Euler formula - link
- URLEncoder. Encode and urldecoder Decode processing URL
- Gorilla/mux framework (RK boot): add tracing Middleware
- Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
猜你喜欢
Pyqt5 sensitive word detection tool production, operator's Gospel
Hcip day 15 notes
Unity shader visualizer shader graph
How to quickly build high availability of service discovery
A preliminary study on the middleware of script Downloader
Pointer concept & character pointer & pointer array yyds dry inventory
How to write a good title of 10w+?
Ppt image processing
How to switch between dual graphics cards of notebook computer
Analysis of refrigeration and air conditioning equipment operation in 2022 and examination question bank of refrigeration and air conditioning equipment operation
随机推荐
D28:maximum sum (maximum sum, translation)
How to quickly build high availability of service discovery
Sword finger offer day 4 (Sword finger offer 03. duplicate numbers in the array, sword finger offer 53 - I. find the number I in the sorted array, and the missing numbers in sword finger offer 53 - ii
[note] glide process and source code analysis
How about opening an account at Hengtai securities? Is it safe?
Pan Yueming helps Germany's Rochester Zodiac custom wristwatch
How about agricultural futures?
IDENTITY
Pointer concept & character pointer & pointer array yyds dry inventory
Blue Bridge Cup -- guess age
Creation of the template of the password management software keepassdx
URLEncoder. Encode and urldecoder Decode processing URL
Mongoose the table associated with the primary key, and automatically bring out the data of another table
IO flow review
Is the controller a single instance or multiple instances? How to ensure the safety of concurrency
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
D26: the nearest number (translation + solution)
C3p0 connection MySQL 8.0.11 configuration problem
A treasure open source software, cross platform terminal artifact tabby
webAssembly