当前位置:网站首页>[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 .
边栏推荐
- 33 restrict the input of qlineedit control (verifier)
- The first game of the new year, many bug awards submitted
- "Learning notes" recursive & recursive
- Pointer concept & character pointer & pointer array yyds dry inventory
- Hcip day 16 notes
- D26: the nearest number (translation + solution)
- Unsafe and CAS principle
- [note] glide process and source code analysis
- webAssembly
- Programming language (1)
猜你喜欢

A treasure open source software, cross platform terminal artifact tabby

How the computer flushes the local DNS cache

How to write a good title of 10w+?

Weekly leetcode - nc9/nc56/nc89/nc126/nc69/nc120

Can you draw with turtle?

Hcip day 16 notes

Pan Yueming helps Germany's Rochester Zodiac custom wristwatch

Overview of Yunxi database executor

Cgb2201 preparatory class evening self-study and lecture content

Runtime. getRuntime(). totalMemory/maxMemory()
随机推荐
Pan Yueming helps Germany's Rochester Zodiac custom wristwatch
Runtime. getRuntime(). totalMemory/maxMemory()
The 2022 global software R & D technology conference was released, and world-class masters such as Turing prize winners attended
Pointer concept & character pointer & pointer array yyds dry inventory
"Learning notes" recursive & recursive
2022 free examination questions for hoisting machinery command and hoisting machinery command theory examination
2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
Text replacement demo
Recursion and recursion
Analysis of refrigeration and air conditioning equipment operation in 2022 and examination question bank of refrigeration and air conditioning equipment operation
How to solve the problem of requiring a password when accessing your network neighborhood on your computer
webAssembly
How to solve win10 black screen with only mouse arrow
2022 examination of safety production management personnel of hazardous chemical production units and examination skills of safety production management personnel of hazardous chemical production unit
Fluent learning (5) GridView
In 2022, 6G development has indeed warmed up
[Android reverse] use DB browser to view and modify SQLite database (download DB browser installation package | install DB browser tool)
Pyqt5 sensitive word detection tool production, operator's Gospel
Recursive least square adjustment
Esp-idf turns off serial port log output.