Sobes.tech
Middle+

Mis juhtub INNER JOIN-is, kui üks rida vasakul vastab mitmele realt paremal?

sobes.tech AI

Vastus AI-lt

In the case of INNER JOIN, if one row from the left table matches multiple rows from the right table, the result will be multiple rows — each combination of the left row with each matching right row. That is, for each row on the left, new rows are created in the result, corresponding to the number of matches on the right.

Example:

-- Table A
id | name
1  | Alice

-- Table B
id | hobby
1  | Chess
1  | Painting

SELECT A.name, B.hobby FROM A INNER JOIN B ON A.id = B.id;

Result:

name hobby
Alice Chess
Alice Painting

Thus, INNER JOIN expands the left rows to all matching right rows.