Theory
A SPARQL SELECT query is a triple pattern with variables prefixed by ?:
SELECT ?ninja WHERE {
?ninja a :Ninja .
}
The engine matches the pattern against the graph and binds ?ninja to every subject that fits.
Think of ?var as a placeholder for any RDF term. The engine tries every node in the graph in that slot, keeps the bindings where the whole pattern matches, and returns one row per surviving binding. Two ?ninja occurrences in the same query must bind to the same term — that's how joins happen (next lesson). Result column names come from the ?var names you write after SELECT.