Junior — Middle
What types of join operators are you familiar with?
sobes.tech AI
Answer from AI
I am familiar with the main types of table join operators in SQL:
- INNER JOIN — returns only the records that match the condition in both tables.
- LEFT JOIN (LEFT OUTER JOIN) — returns all records from the left table and matching records from the right; if there are no matches, NULLs will appear on the right side.
- RIGHT JOIN (RIGHT OUTER JOIN) — similar to LEFT JOIN, but returns all records from the right table.
- FULL JOIN (FULL OUTER JOIN) — returns all records from both tables; where there are no matches, NULLs will appear in the respective fields.
- CROSS JOIN — Cartesian product of two tables, returning all possible combinations of rows.
Example of INNER JOIN in PHP using PDO:
$sql = "SELECT users.name, orders.amount FROM users INNER JOIN orders ON users.id = orders.user_id";
$stmt = $pdo->query($sql);
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);