Reputation:
i'm trying to create a sparql query that returns every column where the column "subject" is "http://purl.org/dc/elements/1.1/creator".
In sql, it should be something like this:
SELECT * WHERE Subject = "<http://purl.org/dc/elements/1.1/creator>"
The sparql query that comes close to what I want looks like this:
SELECT ?subject ?predicate ?object
WHERE {
<http://purl.org/dc/elements/1.1/creator> ?object ?predicate optional {
?subject ?predicate ?object
}
}
It returns a table, with all the three columns, but the ?subject column is empty for some reason. The ?predicate and the ?object column are not empty and show the correct data.
Anyone who can help me with this?
Thanks a lot :D
Upvotes: 2
Views: 1047
Reputation: 22052
There's several ways to do this. Apart from the solution given by Anthony, with a VALUES
clause, you can also use a FILTER
condition:
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .
FILTER(?subject = <http://purl.org/dc/elements/1.1/creator>)
}
or if your goal is not necessarily to get a table with three columns, but to get back all triples with that particular subject, you can also use a CONSTRUCT query:
CONSTRUCT
WHERE { <http://purl.org/dc/elements/1.1/creator> ?predicate ?object }
Upvotes: 2
Reputation: 586
Assuming your Triplestore is populated with the correct statements then try -
SELECT ?subject ?predicate ?object
WHERE {
VALUES ?subject { <http://purl.org/dc/elements/1.1/creator> }
?subject ?predicate ?object .
}
Upvotes: 5