Meaning of SPARQL operator ';'

sparql

Solution

It's not a SPARQL operator, but rather part of the syntax for triple patterns in SPARQL. The full specification is in section 4.2 Syntax for Triples from the SPARQL spec. Subsection 4.2.1 Predicate-Object Lists describes the `;` notation:

Triple patterns with a common subject can be written so that the subject is only written once and is used for more than one triple pattern by employing the ";" notation.

?x  foaf:name  ?name ;
    foaf:mbox  ?mbox .

This is the same as writing the triple patterns:

?x  foaf:name  ?name .
?x  foaf:mbox  ?mbox .

You might also be interested in subsection 4.2.2 Object Lists:

If triple patterns share both subject and predicate, the objects may be separated by ",".

?x foaf:nick  "Alice" , "Alice_" .

is the same as writing the triple patterns:

?x  foaf:nick  "Alice" .
?x  foaf:nick  "Alice_" .

Object lists can be combined with predicate-object lists:

?x  foaf:name ?name ; foaf:nick  "Alice" , "Alice_" .

is equivalent to:

?x  foaf:name  ?name .
?x  foaf:nick  "Alice" .
?x  foaf:nick "Alice_" .

The same syntax is used in Turtle and N3 serializations of RDF. See 2.3 Abbreviating groups of triples for Turtle, which says

The , symbol may be used to repeat the subject and predicate of triples that only differ in the object RDF term. … The ; symbol may be used to repeat the subject of of triples that vary only in predicate and object RDF terms.

and for N3, see the Semantics section, which says:

In property lists, the semicolon ; is shorthand for repeating the subject. In object lists , is shorthand for repeating the verb.

Problem

What does ';' operator in WHERE clause means in SPARQL? For example: ``` SELECT ?x ?y WHERE { ?z foaf:name ?x ; :surname ?y } ``` What the ; operator means here? Is like a logical and that means this part ?z foaf: goes before :surname again?

Original source