Sobes.tech
Junior — Middle

What types of table joins are you familiar with in SQL?

sobes.tech AI

Answer from AI

In SQL, there are several main types of joins that allow combining data from two or more tables:

  • INNER JOIN — returns only the rows with matches in both tables.
  • LEFT JOIN (or LEFT OUTER JOIN) — returns all rows from the left table and matching rows from the right; if there are no matches, NULLs will appear in the right table's columns.
  • RIGHT JOIN (or RIGHT OUTER JOIN) — returns all rows from the right table and matching rows from the left.
  • FULL JOIN (or FULL OUTER JOIN) — returns all rows from both tables, filling in NULLs where there are no matches.
  • CROSS JOIN — Cartesian product, returns all possible combinations of rows from both tables.

Example of INNER JOIN in C# using an SQL query:

string query = @"SELECT Orders.OrderID, Customers.CustomerName 
FROM Orders 
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID";

This query will return orders with customer information for customers who have matching records in both tables.

What types of table joins are you familiar with in… - sobes.tech