Database connection: comparison of Inner Join and Out Join
In the database operation, the connection operation is the key to combining multiple table data. Inner join and Outjoin are two types of connection types. This article will explore their key differences and practical applications.
Inner Join selects two or more columns in different tables. In conceptual point of view, it obtains the intersection of two collection and is expressed in the overlapping part of Ventu. Only in the two tables at the same time will include in the output.
OUTER JOIN: Collection
Unlike Inner Join, OUTER JOIN contains all the rows in the specified table, regardless of whether they have matching in other tables. This operation effectively creates a parallelism that is represented by the combination area of Ventu. Outjoin type
Outjoin is divided into three types:
Right Outr Join:
This query will return only customers who have placed orders.
This query will return to all customers, including customers without orders, the order information will be NULL.
Right Outr Join:<code class="language-sql">SELECT * FROM customer INNER JOIN orders ON customer.id = orders.customer_id;</code>
This query will return all orders, including orders placed by customers in the Customer table, and customer information will be NULL. Full Outr Join:
<code class="language-sql">SELECT * FROM customer LEFT OUTER JOIN orders ON customer.id = orders.customer_id;</code>
This query will return all customers and all orders to fill in the lack of matching items with NULL values.
The above is the detailed content of INNER JOIN vs. OUTER JOIN: What's the Difference and When Should I Use Each?. For more information, please follow other related articles on the PHP Chinese website!