maria-db
  1. maria-db-inner-join

Inner Join - (MariaDB Joins)

In MariaDB, an Inner join is used to combine or join two or more tables based on a related column. The result of the join includes all rows from both tables where the join condition is true.

Syntax

SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

Here, column_name(s) are the column names that you want to select, table1 and table2 are the names of the two tables you want to join, and column_name is the column that is common to both tables.

Example

SELECT customers.customer_name, orders.order_date
FROM customers
INNER JOIN orders
ON customers.customer_id = orders.customer_id;

Output

The output of the join will include all rows from both the customers and orders tables where the customer_id column is the same in both tables.

Explanation

In the above example, we are performing an Inner join operation between two tables – customers and orders. During the join operation, we are matching the customer_id column of both tables. The output of the join will contain only those rows where a customer_id exists in both tables.

Use

Inner join is used to combine related data from two or more tables in MariaDB. This enables you to extract data from two or more tables and present it as a single result set.

Important Points

  • Inner join is used to combine related data from two or more tables based on a common column.
  • Inner join only includes records from both tables where the join condition is true.
  • Inner join is used to extract related data from multiple tables and present it as a single result set.

Summary

The Inner join in MariaDB is a powerful and flexible way to extract related data from multiple tables and present it as a single result set. This can be useful in a variety of applications where data from multiple tables needs to be combined in a meaningful way, such as reports and dashboards.

Published on: