Home > Database > Mysql Tutorial > The difference between inner joins and outer joins in SQL

The difference between inner joins and outer joins in SQL

PHPz
Release: 2023-09-13 12:29:09
forward
1037 people have browsed it

The difference between inner joins and outer joins in SQL

In this article, we will understand the difference between inner join and outer join in SQL.

Inner join

  • clause uses "INNER JOIN" and "JOIN".

  • It returns a combined tuple of two or more tables.

  • When there are no common attributes, the result is empty.

  • "INNER JOIN" works faster than "OUTER" if the number of tuples is larger JOIN'.

  • Used when detailed information about a specific property is required.

  • 'JOIN' and 'INNER JOIN' work the same way.

Syntax

SELECT *
FROM table_1 INNER JOIN / JOIN table_2
ON table_1.column_name = table_2.column_name;
Copy after login

Outer Join

  • Returns the combined tuple of the specified table.

  • Returns even if the "JOIN" condition fails.

  • You can use the clauses LEFT OUTER JOIN, RIGHT OUTER JOIN, FULL OUTER JOIN.

  • Does not depend on public properties.

  • If the property is empty , then NULL is placed instead of blank.

  • Compared with "INNER JOIN", "OUTER JOIN" is slower.

  • It is Use when complete information is required.

  • FULL OUTER JOIN and FULL JOIN clauses work the same way.

Syntax

SELECT *
FROM table_1 LEFT OUTER JOIN / RIGHT OUTER JOIN /
FULL OUTER JOIN / FULL JOIN table_2 ON
Table_1.column_name = table_2.column_name;
Copy after login

The above is the detailed content of The difference between inner joins and outer joins in SQL. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template