SQL Joins
SQL joins are used to combine rows from two or more tables based on a related column between them. This allows you to retrieve data from multiple tables in a single query.
Types of SQL joins:
INNER JOIN
Returns rows when there is at least one match in both tables. Example:
SELECT *
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
LEFT JOIN
Also - LEFT OUTER JOIN. Returns all rows from the left table and the matched rows from the right table. If there is no match, NULL values are returned. Example:
SELECT *
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;
RIGHT JOIN
Also - RIGHT OUTER JOIN. Returns all rows from the right table and the matched rows from the left table. If there is no match, NULL values are returned. Example:
SELECT *
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
FULL JOIN
Also - FULL OUTER JOIN. Returns rows when there is a match in one of the tables. It combines the results of both LEFT JOIN and RIGHT JOIN. Example:
SELECT *
FROM table1
FULL JOIN table2
ON table1.column_name = table2.column_name;
SQL Joins help merge data from different tables based on common columns, making it easier to fetch information from multiple sources in a single query.
Semantic portal



