Sobes.tech
Junior — Middle

What types of table joins have you used in your SQL queries?

sobes.tech AI

Answer from AI

Various types of table joins (JOIN) are used in SQL queries to combine data from multiple tables:

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

Example of INNER JOIN:

SELECT users.name, orders.amount
FROM users
INNER JOIN orders ON users.id = orders.user_id;

This query will return the names of users and their order amounts, only for users who have orders.

What types of table joins have you used in your SQL… - sobes.tech