Junior — Middle
Kuidas saab andmebaasis ühendada mitme tabeli teavet?
sobes.tech AI
Vastus AI-lt
Combining information from multiple tables in a database can be done using JOIN operations. JOIN allows you to link rows from different tables based on a common field.
Main types of JOIN:
- INNER JOIN — returns only matching records from both tables.
- LEFT JOIN (or LEFT OUTER JOIN) — returns all records from the left table and matching records from the right, if any.
- RIGHT JOIN — the opposite, all from the right and matching from the left.
- FULL JOIN — all records from both tables, with NULL where there are no matches.
Example SQL query that joins "orders" and "customers" tables on the customer_id field:
SELECT orders.id, customers.name, orders.total
FROM orders
INNER JOIN customers ON orders.customer_id = customers.id;
In QA automation, such queries can be used to verify data integrity or to prepare test data.