当前位置:网站首页>[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 .
边栏推荐
- Day30-t540-2022-02-14-don't answer by yourself
- JarPath
- Take you to master the formatter of visual studio code
- FPGA tutorial and Allegro tutorial - link
- Recursion and recursion
- Maxwell equation and Euler formula - link
- 炒股开户佣金优惠怎么才能获得,网上开户安全吗
- Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
- 股票开户最低佣金炒股开户免费,网上开户安全吗
- Is the controller a single instance or multiple instances? How to ensure the safety of concurrency
猜你喜欢

Selenium check box

2022.02.13

Hcip day 15 notes

Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?

Interpretation of corolla sub low configuration, three cylinder power configuration, CVT fuel saving and smooth, safety configuration is in place

2022 a special equipment related management (elevator) examination questions and a special equipment related management (elevator) examination contents

How to write a good title of 10w+?

C deep anatomy - the concept of keywords and variables # dry inventory #
![Yyds dry goods inventory [practical] simply encapsulate JS cycle with FP idea~](/img/af/1975b37d81bbdb9709ff181b9a72f9.jpg)
Yyds dry goods inventory [practical] simply encapsulate JS cycle with FP idea~
Creation of the template of the password management software keepassdx
随机推荐
File copy method
Format cluster and start cluster
Subset enumeration method
Interesting 10 CMD commands
How can enterprises and developers take advantage of the explosion of cloud native landing?
Go error collection | talk about the difference between the value type and pointer type of the method receiver
"Learning notes" recursive & recursive
Schematic diagram of crystal oscillator clock and PCB Design Guide
How to quickly build high availability of service discovery
D25:sequence search (sequence search, translation + problem solving)
[automation operation and maintenance novice village] flask-2 certification
Live app source code, jump to links outside the station or jump to pages inside the platform
2022.02.14
2022 free examination questions for hoisting machinery command and hoisting machinery command theory examination
Opengauss database log management guide
. Net ADO splicing SQL statement with parameters
What are the securities companies with the lowest Commission for stock account opening? Would you recommend it? Is it safe to open an account on your mobile phone
C3p0 connection MySQL 8.0.11 configuration problem
C # basic knowledge (1)
C summary of knowledge point definitions, summary notes