当前位置:网站首页>[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 connectionin ,(+)Indicates which is from the table .OracleYes SQL92 Better support , andMySQLDo 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...ONClause creates the syntax structure of the join : - SQL99 Use... In grammar
JOIN ...ONTo 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 .
边栏推荐
- [note] glide process and source code analysis
- finalize finalization finally final
- 2022 a special equipment related management (elevator) examination questions and a special equipment related management (elevator) examination contents
- How can enterprises and developers take advantage of the explosion of cloud native landing?
- Recursive least square adjustment
- D27:mode of sequence (maximum, translation)
- pycuda._ driver. LogicError: explicit_ context_ dependent failed: invalid device context - no currently
- Opengauss database log management guide
- Druids connect to mysql8.0.11
- 2/14 (regular expression, sed streaming editor)
猜你喜欢

How to understand the gain bandwidth product operational amplifier gain

Summary of fluent systemchrome

2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination

Unique in China! Alibaba cloud container service enters the Forrester leader quadrant

540. Single element in ordered array

Format cluster and start cluster

Opengauss database log management guide

Actual combat | use composite material 3 in application

A preliminary study on the middleware of script Downloader

2/14 (regular expression, sed streaming editor)
随机推荐
Format cluster and start cluster
"Learning notes" recursive & recursive
D29:post Office (post office, translation)
Actual combat | use composite material 3 in application
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
Qtoolbutton available signal
Minimum commission for stock account opening. Stock account opening is free. Is online account opening safe
finalize finalization finally final
2022 free examination questions for hoisting machinery command and hoisting machinery command theory examination
"Learning notes" recursive & recursive
Quick one click batch adding video text watermark and modifying video size simple tutorial
Fashion cloud interview questions series - JS high-frequency handwritten code questions
Day30-t540-2022-02-14-don't answer by yourself
Live app source code, jump to links outside the station or jump to pages inside the platform
To rotate 90 degrees clockwise and modify the video format
URLEncoder. Encode and urldecoder Decode processing URL
The reason why the computer runs slowly and how to solve it
D23:multiple of 3 or 5 (multiple of 3 or 5, translation + solution)
2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) simulated examination and Guangdong Provincial Safety Officer a certificate third batch (main person in charg
Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)