Theory
Two patterns sharing a variable form an implicit join:
SELECT ?ninja ?master WHERE {
?ninja a :Ninja .
?master :teaches ?ninja .
}
The engine returns every (ninja, master) pair where the master teaches a known ninja.
Why it works: a row is kept only if every triple pattern matches with the same binding for any variable that appears more than once. In the example, ?ninja must be the same node in both patterns, which is exactly an inner join on ?ninja. Same idea in tabular form:
| Pattern | Binds |
|---|---|
?ninja a :Ninja . | ?ninja → every Ninja |
?master :teaches ?ninja . | + ?master per pair |