An introduction to RDF querying in SPARQL
Zwifi
20.9K views
Projection
Binding in the SELECT clause
1
2
3
4
5
6
7
8
9
10
11
PREFIX yaco: <https://www.irit.fr/recherches/MELODI/ontologies/cinema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?actor (?curYear-?birthYear AS ?age)
WHERE {
?actor rdf:type yaco:Actor;
yaco:birthYear ?birthYear.
BIND(year(now()) as ?curYear)
}
1
@prefix yaco: <https://www.irit.fr/recherches/MELODI/ontologies/cinema#> .
Binding for reuse in the WHERE clause
1
2
3
4
5
6
7
8
9
10
11
PREFIX yaco: <https://www.irit.fr/recherches/MELODI/ontologies/cinema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?actor ?age
WHERE {
?actor rdf:type yaco:Actor;
yaco:birthYear ?birthYear.
BIND(year(now())-?birthYear AS ?age)
}
1
@prefix yaco: <https://www.irit.fr/recherches/MELODI/ontologies/cinema#> .
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.