Junior
Mis on JOIN operaator SQL-is?
sobes.tech AI
Vastus AI-lt
The SQL operator JOIN is used to combine rows from two or more tables based on a related column between them.
Main types of JOIN:
INNER JOIN: Returns rows that have matching values in both tables.LEFT JOIN(orLEFT OUTER JOIN): Returns all rows from the left table and the matching rows from the right table. If there is no match, the result from the right table containsNULL.RIGHT JOIN(orRIGHT OUTER JOIN): Returns all rows from the right table and the matching rows from the left table. If there is no match, the result from the left table containsNULL.FULL JOIN(orFULL OUTER JOIN): Returns all rows where there is a match in either the left or right table. The result contains all rows from both tables, filling withNULLfor non-matching rows.CROSS JOIN: Returns the Cartesian product of rows from both tables. This is equivalent to a join without anONcondition.
Example of INNER JOIN:
SELECT
Customers.CustomerName,
Orders.OrderID
FROM
Customers
INNER JOIN
Orders
ON
Customers.CustomerID = Orders.CustomerID;