Junior
168
Kuidas ühe päringuga valida andmeid kahest tabelist?
Vastus AI-lt
sobes.tech AI
You can use JOIN in SQL. It combines rows from two or more tables based on a related column between them.
Types of JOIN:
- INNER JOIN: Selects rows that have matching values in both tables.
- LEFT (OUTER) JOIN: Selects all rows from the left table and the matching rows from the right table. If there is no match, the columns from the right table will be NULL.
- RIGHT (OUTER) JOIN: Selects all rows from the right table and the matching rows from the left table. If there is no match, the columns from the left table will be NULL.
- FULL (OUTER) JOIN: Selects all rows where there is a match in either table.
Example of INNER JOIN:
SELECT
table1.column1,
table2.column2
FROM
table1
INNER JOIN
table2
ON
table1.common_column = table2.common_column;